#include #define int ll using namespace std; #define rep(i,n) for(int i=0;i=0;i--) #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define vec(...) vector<__VA_ARGS__> #define _3k5NXAD ios::sync_with_stdio(0),cin.tie(0) typedef long long ll; using pii=pair; using vi=vector; void print(){cout<<'\n';} template void print(const h&v,const t&...u){cout< par,siz; dsu(int m){init(m);} void init(int m){ n=m; cmps=m; par.resize(n,0); siz.resize(n,0); for(int i=0;i>n; vi a(n); rep(i,n){ cin>>a[i]; } const int nax=100001; vec(vi) rbts(nax); rep(i,n){ rbts[a[i]].pb(i); } using tup=tuple; vec(tup) edges; rng(i,1,nax){ int rt=-1,irt=-1; for(int j=i;j