# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define scn(x) scanf("%I64d",&x)
# define scan(x) scanf("%d",&x)
# define print(x) printf("%d ",x)
# define prnt(x) printf("%I64d ",x);
# define eol printf("\n")
# define IOS ios_base :: sync_with_stdio(0)
int s[1 << 20];
int main(void)
{
int t;
scan(t);
while (t --)
{
int n;
scan(n);
int mn = 1e9;
for (int i = 1;i <= n;++i) scan(s[i]),mn = min(mn,s[i]);
int ans = 0;
vector < int > can;
for (int i = 1;i * i <= mn;++i)
if (!(mn % i))
{
can.push_back(i);
if (1ll * i * i != mn) can.push_back(mn / i);
}
for (auto P : can)
{
int G = 0;
for (int i = 1;i <= n;++i)
if (s[i] % P) G = __gcd(G,s[i]);
if (!G) G = 1e9;
ans = max(ans,min(G,P));
}
print(ans);eol;
}
return 0;
}
IyBpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojIGRlZmluZSBmaSBjaW4KIyBkZWZpbmUgZm8gY291dAojIGRlZmluZSB4IGZpcnN0CiMgZGVmaW5lIHkgc2Vjb25kCiMgZGVmaW5lIGxsIGxvbmcgbG9uZwojIGRlZmluZSBkYiBsb25nIGRvdWJsZQojIGRlZmluZSBzY24oeCkgc2NhbmYoIiVJNjRkIiwmeCkKIyBkZWZpbmUgc2Nhbih4KSBzY2FuZigiJWQiLCZ4KQojIGRlZmluZSBwcmludCh4KSBwcmludGYoIiVkICIseCkKIyBkZWZpbmUgcHJudCh4KSBwcmludGYoIiVJNjRkICIseCk7CiMgZGVmaW5lIGVvbCBwcmludGYoIlxuIikKIyBkZWZpbmUgSU9TIGlvc19iYXNlIDo6IHN5bmNfd2l0aF9zdGRpbygwKQppbnQgc1sxIDw8IDIwXTsKaW50IG1haW4odm9pZCkKewogICAgaW50IHQ7CiAgICBzY2FuKHQpOwogICAgd2hpbGUgKHQgLS0pCiAgICB7CiAgICAgICAgaW50IG47CiAgICAgICAgc2NhbihuKTsKICAgICAgICBpbnQgbW4gPSAxZTk7CiAgICAgICAgZm9yIChpbnQgaSA9IDE7aSA8PSBuOysraSkgc2NhbihzW2ldKSxtbiA9IG1pbihtbixzW2ldKTsKICAgICAgICBpbnQgYW5zID0gMDsKICAgICAgICB2ZWN0b3IgPCBpbnQgPiBjYW47CiAgICAgICAgZm9yIChpbnQgaSA9IDE7aSAqIGkgPD0gbW47KytpKQogICAgICAgICAgICBpZiAoIShtbiAlIGkpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjYW4ucHVzaF9iYWNrKGkpOwogICAgICAgICAgICAgICAgaWYgKDFsbCAqIGkgKiBpICE9IG1uKSBjYW4ucHVzaF9iYWNrKG1uIC8gaSk7CiAgICAgICAgICAgIH0KICAgICAgICBmb3IgKGF1dG8gUCA6IGNhbikKICAgICAgICB7CiAgICAgICAgICAgIGludCBHID0gMDsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDE7aSA8PSBuOysraSkKICAgICAgICAgICAgICAgIGlmIChzW2ldICUgUCkgRyA9IF9fZ2NkKEcsc1tpXSk7CiAgICAgICAgICAgIGlmICghRykgRyA9IDFlOTsKICAgICAgICAgICAgYW5zID0gbWF4KGFucyxtaW4oRyxQKSk7CiAgICAgICAgfQogICAgICAgIHByaW50KGFucyk7ZW9sOwogICAgfQogICAgcmV0dXJuIDA7Cn0KCg==