#include <bits/stdc++.h>
using namespace std;
void read(long long &x) { scanf("%lld", &x); }
void read(long long &x, long long &y) { scanf("%lld%lld", &x, &y); }
void read(long long &x, long long &y, long long &z) {
  scanf("%lld%lld%lld", &x, &y, &z);
}
void print(long long x) { printf("%lld ", x); }
void println(long long x) { printf("%lld\n", x); }
const long long N = 300100;
long long q, n, a[N], ans, b[N], sz;
int main() {
  cin >> q;
  for (; q--;) {
    read(n);
    for (long long i = 1; i <= n; i++) read(a[i]);
    sort(a + 1, a + n + 1);
    sz = 0;
    for (long long i = 1; i <= n; i++)
      if (i == 1 || a[i] != a[i - 1]) b[++sz] = a[i];
    reverse(b + 1, b + sz + 1);
    for (long long i = 1; i <= sz; i++) a[i] = b[i];
    n = sz;
    ans = a[1];
    for (long long i = 1; i <= min(59LL, n); i++)
      for (long long j = i + 1; j <= (i + 59LL, n); j++)
        if (a[i] % a[j] != 0) ans = max(ans, a[i] + a[j]), j = n;
    for (long long i = 1; i <= min(59LL, n); i++) {
      if (i + 2 <= n && a[i] + a[i + 1] + a[i + 2] <= ans) break;
      for (long long j = i + 1; j <= (i + 59LL, n); j++)
        if (a[i] % a[j] != 0) {
          if (j < n && a[i] + a[j] + a[j + 1] <= ans) break;
          for (long long k = j + 1; k <= min(j + 59LL, n); k++)
            if (a[i] % a[k] != 0 && a[j] % a[k] != 0)
              ans = max(ans, a[i] + a[j] + a[k]), k = n;
        }
    }
    println(ans);
  }
}
