// Make the best become better // No room for laziness #include #define int long long #define pb push_back #define fi first #define se second using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxN = 1e6 + 5; const int mod = 1e9 + 7; const ll oo = 1e18; int n; int a[maxN]; vector vc[maxN]; vector L[maxN]; int lab[maxN]; int Findset(int u) { return lab[u] < 0 ? u : lab[u] = Findset(lab[u]); } bool Unite(int u, int v) { int r = Findset(u), s = Findset(v); if(r == s) return false; if(lab[r] > lab[s]) swap(r, s); lab[r] += lab[s]; lab[s] = r; return true; } struct TEdge { int u, v, w; }; vector e; void ReadInput() { cin >> n; for(int i=1; i<=n; i++) { cin >> a[i]; vc[a[i]].pb(i); } } void Solve() { for(int i=1; i 1) vc[i].pop_back(); } for(int i=1; i