#include //#include //#include #include #include //#include #include //#include //#include //#include //#include //#include using namespace std ; using ll = long long ; //using ld = long double ; using vll = vector ; using vvll = vector ; //using vc = vector ; //using vvc = vector ; //using vb = vector ; //using vvb = vector ; //using pll = pair ; //#define all(v) v.begin(),v.end() //ll mod = 1000000007 ; //long double pie = acos(-1) ; //ll INF = 1000000000000 ; //void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;} //void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;} //ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;} //ll lcm(long long a,long long b){return a/gcd(a,b)*b ;} //ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;} //void fix_cout(){cout << fixed << setprecision(20) ;} //void chmin(ll &a,ll b){if(a>b) a = b ;} int main(){ ll n ; cin >> n ; ll f,l ; set s ; vvll cnt(n+1,vll(0)) ; for(int i=0;i> a ; s.insert(a) ; if(i==0) f = a ; if(i==n-1) l = a ; cnt.at(a).emplace_back(i+1) ; } for(int i=0;i<=n;i++){ if(cnt.at(i).size()<2) continue ; if(cnt.at(i).at(0)==1){ vll sub ; for(int j=0;j