#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<unordered_map>
using namespace std;
const int N = 1e6 + 10,null = 0x3f3f3f3f;
int t,n;
int a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> t;
unordered_map<int,int> s;
while(t--)
{
cin >> n;
for(int i = 1;i <= n;i++)
{
cin >> a[i];
}
long long res = 0;
for(long long i = 1, j = 1;i <= n;i++)
{
s[a[i]]++;
while(s[a[i]] > 1)
{
j++;
s[a[i]]--;
}
res = max(res,i - j + 1);
}
cout << res << endl;
memset(a, 0, sizeof a);
s.clear();
}
return 0;
}