#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int solve() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  reverse(a.begin(), a.end());
  n = a.size();
  int res = a[0];
  for (int i = 0; i < n; ++i) {
    int j = i + 1;
    while (j < n && a[i] % a[j] == 0) ++j;
    if (j < n) res = max(res, a[i] + a[j]);
  }
  for (int i = 0; i < n; ++i) {
    vector<int> z;
    for (int j = i + 1; j <= i + 300 && j < n; ++j)
      if (a[i] % a[j]) z.push_back(j);
    while (z.size() > 100) z.pop_back();
    for (int e = 0; e < z.size(); ++e) {
      int j = z[e] + 1;
      while (j < n && (a[i] % a[j] == 0 || a[z[e]] % a[j] == 0)) ++j;
      if (j < n) res = max(res, a[i] + a[z[e]] + a[j]);
    }
  }
  return res;
}
int f(int x) {
  int res = 0;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i) continue;
    res += 2;
    if (i * i == x) res -= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) cout << solve() << "\n";
  return 0;
}
