#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b>n>>p>>q;p--,q--; vector a(n); rep(i,n){ cin>>a[i];a[i]--; } if(!next_permutation(ALL(a))){ cout<<-1< ans(n); set st;rep(i,n)st.insert(i); rep(i,n){ if(f){ auto ite=st.begin(); if(*ite==q and !pf){ ite=next(ite); if(ite==st.end()){ cout<<-1<