#include <bits/stdc++.h>
using namespace std;
struct fastin {
  template <typename T>
  fastin operator>>(T &i) {
    i = 0;
    int f = 1;
    char c;
    do {
      c = getchar();
      if (c == '-') f = -1;
    } while (c < '0' || c > '9');
    while (isdigit(c)) i = i * 10 + c - '0', c = getchar();
    i *= f;
    return *this;
  }
} fin;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7, N = 2e5 + 5;
int a[N];
bool tag[N];
int solve(int *r, int n) {
  if (n == 1) return r[0];
  if (n == 2) {
    return r[0] + ((r[0] % r[1]) ? r[1] : 0);
  }
  for (long long i = 1; i < n; ++i) {
    tag[i] = !!(r[0] % r[i]);
  }
  int res[3] = {}, rec = 0, pes[3] = {}, pec = 0;
  for (long long i = 1; i < n; ++i) {
    if (!tag[i]) {
      if (rec < 3) res[rec++] = i;
    } else {
      if (pec < 3) pes[pec++] = i;
    }
    if (rec == 3 && pec == 3) break;
  }
  int ans = r[0];
  if (pec >= 1) ans += r[pes[0]];
  if (pec > 1) {
    for (long long i = pes[0] + 1; i < n; ++i) {
      if (tag[i] && (r[pes[0]] % r[i])) {
        ans += r[i];
        break;
      }
    }
  }
  if (rec == 3 && r[0] / r[res[0]] == 2 && r[0] / r[res[1]] == 3 &&
      r[0] / r[res[2]] == 5) {
    return max(r[res[0]] + r[res[1]] + r[res[2]], ans);
  }
  return ans;
}
int main() {
  int T;
  fin >> T;
  while (T--) {
    int n;
    fin >> n;
    for (long long i = 0; i < n; ++i) fin >> a[i];
    sort(a, a + n, greater<int>());
    n = unique(a, a + n) - a;
    printf("%d\n", solve(a, n));
  }
  return 0;
}
