#include<bits/stdc++.h> usingnamespacestd; constint N = 1e6 + 5; int t, n, a[N]; map<int, int> cnt; intmain(){ cin >> t; while (t--) { int ans = 1; cnt.clear(); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int l = 1, r = 1, rep = 0; cnt[a[1]] = 1; while (l <= r && r <= n) { if (rep == 0) { ans = max(ans, r - l + 1); r++; cnt[a[r]]++; if (cnt[a[r]] > 1) rep++; } else { cnt[a[l]]--; if (cnt[a[l]] == 1) rep--; l++; } } cout << ans << endl; } return0; }