#include <bits/stdc++.h>
#define ll long long
#define endll '\n';
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
const int mod = 1e9 + 7, N = 1e6;
void solve()
{
int n; cin >> n;
int ar[n + 3];
for(int i = 1; i <= n; i++) {
cin >> ar[i];
}
int even = n / 2 , odd = n - even, ans = 0;
for(int i = 1; i <= 100; i++) {
int cnt = 0, gcd1 = 0, gcd2 = 0;
for(int j = 1; j <= n; j++) {
if(ar[j] % i == 0 && cnt < min(even, odd)) {
cnt++;
}
else {
gcd1 = __gcd(gcd1, ar[j]);
}
}
if(cnt == min(even, odd)) {
ans = max (ans, i + gcd1);
}
}
cout << ans << endll;
}
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}