/*
PROG: ride
LANG : C++
*/
#include<stdio.h>
//#include<stdlib.h>
//#include<iostream>
#include<string.h>
//#include<conio.h>
#include<math.h>
//#include<algorithm>
//#define int char
//#define clrscr() 100
//#define INFINITY 99999
//using namespace std;
//#define FOR(i,a,b) for(int i=a;i<b;i++)
long int gcd( long int a1, long int b1)
{
/*unsigned long long int t1;
while(b1!=0)
{
t1 = b1;
b1 = a1%b1;
a1 = t1;
}
return a1;*/
if (!b1) return a1;
return gcd(b1,a1%b1);
}
int main()
{
long int t,n,a[100002],i;
long int temp;
//cin>>t;
scanf("%ld",&t);
while(t--)
{
//cin>>n;
scanf("%ld",&n);
//cin>>a[0];
scanf("%ld",&a[0]);
temp=a[0];
//FOR(i,1,n)
for( i=1;i<n;i++)
{
//cin>>a[i];
scanf("%ld",&a[i]);
temp=gcd(temp,a[i]);
}
//cout<<temp<<"\n";
if(temp>1)
{
//FOR(i,2,temp)
for( i=2;i<=temp/2;i++)
{
if(temp%i==0)
{
//temp=i;
break;
}
}
// cout<<temp<<"\n";
printf("%ld\n",i);
}
else //cout<<"-1\n";
printf("-1\n");
}
return 0;
}
LyoKICAgIFBST0c6IHJpZGUKICAgIExBTkcgOiBDKysKKi8KIAojaW5jbHVkZTxzdGRpby5oPgovLyNpbmNsdWRlPHN0ZGxpYi5oPgovLyNpbmNsdWRlPGlvc3RyZWFtPgojaW5jbHVkZTxzdHJpbmcuaD4KLy8jaW5jbHVkZTxjb25pby5oPgojaW5jbHVkZTxtYXRoLmg+Ci8vI2luY2x1ZGU8YWxnb3JpdGhtPgovLyNkZWZpbmUgaW50IGNoYXIKLy8jZGVmaW5lIGNscnNjcigpIDEwMAovLyNkZWZpbmUgSU5GSU5JVFkgOTk5OTkKIAogCiAKLy91c2luZyBuYW1lc3BhY2Ugc3RkOwovLyNkZWZpbmUgRk9SKGksYSxiKSBmb3IoaW50IGk9YTtpPGI7aSsrKQogCiAKIAogCiAKIAogCiAKIGxvbmcgaW50IGdjZCggbG9uZyBpbnQgYTEsIGxvbmcgaW50IGIxKQp7CiAgICAvKnVuc2lnbmVkIGxvbmcgbG9uZyBpbnQgdDE7CiAgICB3aGlsZShiMSE9MCkKICAgIHsKICAgICAgICB0MSA9IGIxOwogICAgICAgIGIxID0gYTElYjE7IAogICAgICAgIGExID0gdDE7CiAgICB9IAogICAgCiAgICByZXR1cm4gYTE7Ki8KICAgICBpZiAoIWIxKSByZXR1cm4gYTE7CiAgICByZXR1cm4gZ2NkKGIxLGExJWIxKTsKfQogCiAKaW50IG1haW4oKQp7CiAgIGxvbmcgaW50IHQsbixhWzEwMDAwMl0saTsKICAgIGxvbmcgaW50IHRlbXA7CiAgICAvL2Npbj4+dDsKICAgIHNjYW5mKCIlbGQiLCZ0KTsKICAgIHdoaWxlKHQtLSkKICAgIHsKICAgICAgICAvL2Npbj4+bjsKICAgICAgICBzY2FuZigiJWxkIiwmbik7CiAgICAgICAgLy9jaW4+PmFbMF07CiAgICAgICAgc2NhbmYoIiVsZCIsJmFbMF0pOwogICAgICAgIHRlbXA9YVswXTsKICAgICAgICAvL0ZPUihpLDEsbikKICAgICAgICBmb3IoIGk9MTtpPG47aSsrKQogICAgICAgIHsKICAgICAgICAgICAgLy9jaW4+PmFbaV07CiAgICAgICAgICAgIHNjYW5mKCIlbGQiLCZhW2ldKTsKICAgICAgICAgICAgdGVtcD1nY2QodGVtcCxhW2ldKTsKICAgICAgICB9CiAgICAgICAgLy9jb3V0PDx0ZW1wPDwiXG4iOwogICAgICAgIGlmKHRlbXA+MSkKICAgICAgIHsKICAgICAgICAgICAKICAgICAgICAgICAgLy9GT1IoaSwyLHRlbXApCiAgICAgICAgICAgIGZvciggaT0yO2k8PXRlbXAvMjtpKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKHRlbXAlaT09MCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAvL3RlbXA9aTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgIC8vIGNvdXQ8PHRlbXA8PCJcbiI7ICAgIAogICAgICAgICAgIHByaW50ZigiJWxkXG4iLGkpOwogICAgICAgIH0KICAgICAgICBlbHNlIC8vY291dDw8Ii0xXG4iOwogICAgICAgIHByaW50ZigiLTFcbiIpOwogICAgICAgIAogICAgfQogICAgcmV0dXJuIDA7Cn0gIAo=