#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 10;
const ll MOD = 1e9 + 7;
int n, ans = 0;
void max_gcd(int ind, vector<int> &v, int gc, int gc2, int cnt) {
if(ind == n) {
if(cnt == (n + 1) / 2) {
ans = max(ans, gc + gc2);
}
return;
}
int a = gcd(gc, v[ind]);
int b = gcd(gc2, v[ind]);
max_gcd(ind + 1, v, a, gc2, cnt + 1);
max_gcd(ind + 1, v, gc, b, cnt);
}
void solve()
{
cin >> n;
vector<int> v(n);
for(int i = 0; i < n; i++) {
cin >> v[i];
}
ans = 0;
max_gcd(0, v, 0, 0, 0);
cout << ans << "\n";
}
int main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int t;
cin >> t;
while(t--){
solve();
}
}