#include<bits/stdc++.h> usingnamespace std; #define ll long long constint maxn = 1e6 + 10; int t, n; int a[maxn]; map<int, int>mp; int pos[maxn]; intmain(){ scanf("%d", &t); while (t--) { mp.clear(); scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { if (!mp.count(a[i])) { mp[a[i]] = i; pos[i] = -1; } else { pos[i] = mp[a[i]]; mp[a[i]] = i; } } int L = 0, R = 0; int ans = 1; while (R < n - 1) { if (pos[R + 1] < L) { R++; ans = max(ans, R - L + 1); } else { R++; L = pos[R] + 1; } } cout << ans << endl; } return0; }