#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int check(LL x)
{
LL num=sqrtl(1LL*x);
if(num*num==x) return 1;
else return 0;
}
int main()
{
int T;cin>>T;
while(T--)
{
int n;cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++) cin>>a[i];
int ans=1;
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
{
int d=a[j]-a[i];
for(int x=1;x*x<=d;x++)
{
int y=d/x;
if((x-y)%2) continue;
int A=(y-x)/2;
int B=(y+x)/2;
if(a[i]>1LL*A*A) continue;
LL X=1LL*A*A-a[i];
int res=0;
for(int k=0;k<n;k++)
res+=check(a[k]+X);
ans=max(ans,res);
}
}
cout<<ans<<endl;
}
return 0;
}