#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int N;
cin >> N;
vector<int> A(N);
int maxA = 0;
for(int i = 0; i < N; i++){
cin >> A[i];
maxA = max(maxA, A[i]);
}
int kodd = (N + 1) / 2;
int keven = N / 2;
vector<int> freq(maxA+1, 0);
for(int x : A) freq[x]++;
// cnt[d] = number of elements divisible by d
vector<int> cnt(maxA+1, 0);
for(int d = 1; d <= maxA; d++){
for(int m = d; m <= maxA; m += d)
cnt[d] += freq[m];
}
// collect candidates
vector<int> Xs, Ys;
for(int d = 1; d <= maxA; d++){
if(cnt[d] >= kodd) Xs.push_back(d);
if(cnt[d] >= keven) Ys.push_back(d);
}
ll best = 0;
for(int X : Xs){
for(int Y : Ys){
ll L = lcm<ll>(X, Y);
int inter = (L <= maxA ? cnt[L] : 0);
int covered = cnt[X] + cnt[Y] - inter;
if(covered == N){
best = max(best, (ll)X + Y);
}
}
}
cout << best << '\n';
}
return 0;
}