#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma comment(linker, "/stack:200000000")
using namespace std;
const int mod0 = 1e9 + 7;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 9;
const long long mod3 = 2147483647;
const int sz = 512 * 1024;
const long long inf = 2 * 1024 * 1024 * 1023 - 1;
const long long INF = inf * inf;
const long double eps = 1e-7;
const int N = 2e5 + 5;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(16);
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> set1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    set1.insert(a[i]);
  }
  sort(a.begin(), a.end());
  int mx = *set1.rbegin();
  int ans = a.back();
  vector<int> A;
  A.push_back(a.back());
  for (int i = n - 2; i >= 0; --i) {
    bool flag = 1;
    for (int x : A) {
      if (x % a[i] == 0) flag = 0;
    }
    if (!flag) continue;
    A.push_back(a[i]);
    ans += a[i];
    if (A.size() == 3) break;
  }
  if ((set1.find(mx / 2) != set1.end()) && (set1.find(mx / 3) != set1.end()) &&
      (set1.find(mx / 5) != set1.end()) && mx % 30 == 0)
    ans = max(ans, mx / 2 + mx / 3 + mx / 5);
  cout << ans << '\n';
}
int main() {
  init();
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) solve();
}
