#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int maxn=100005; int par[maxn]; int Find(int x){return x==par[x]?x:par[x]=Find(par[x]);} signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); int n; cin >> n; vector a(n),cnt(maxn); vector> e; for(int i=0; i> i,cnt[i]++; ll res=0; for(int i=1; i vec; for(int j=i; j