#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define nl "\n"
#define all(x) (x).begin(), (x).end()
#define Yes cout<<"Yes"<<"\n";
#define No cout<<"No"<<"\n";
int gcdArray(const vector<int>& arr) {
return accumulate(all(arr), arr[0], [](int a, int b) { return __gcd(a, b); });
}
int maxGCDSum(vector<int>& A) {
int n = A.size();
vector<int> indices(n);
iota(all(indices), 0);
int maxSum = 0;
do {
vector<int> oddIndexed, evenIndexed;
for (int i = 0; i < n;i++) {
if (i % 2 == 0) {
evenIndexed.push_back(A[indices[i]]);
} else {
oddIndexed.push_back(A[indices[i]]);
}
}
int oddGCD = gcdArray(oddIndexed);
int evenGCD = gcdArray(evenIndexed);
maxSum = max(maxSum, oddGCD + evenGCD);
} while (next_permutation(all(indices)));
return maxSum;
}
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];
}
cout << maxGCDSum(A) <<nl;
}
return 0;
}