#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long INF = 1e18;
const long long M = 1e9 + 7;
const long long maxn = 2e5 + 5;
long long a[maxn];
signed main() {
  long long q;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    for (long long i = 0; i < n; ++i) {
      cin >> a[i];
    }
    sort(a, a + n);
    n = unique(a, a + n) - a;
    reverse(a, a + n);
    long long res = a[0];
    for (long long i = 0; i < n; ++i) {
      for (long long j = i + 1; j < n && a[i] + a[j] > res; ++j) {
        if (a[i] % a[j] != 0) {
          res = max(res, a[i] + a[j]);
          break;
        }
      }
    }
    for (long long i = 0; i < n - 2 && a[i] + a[i + 1] + a[i + 2] > res; ++i) {
      for (long long j = i + 1; j < n - 1 && a[i] + a[j] + a[j + 1] > res;
           ++j) {
        if (a[i] % a[j] != 0) {
          for (long long k = j + 1; k < n && a[i] + a[j] + a[k] > res; ++k) {
            if (a[i] % a[k] != 0 && a[j] % a[k] != 0) {
              res = max(res, a[i] + a[j] + a[k]);
              break;
            }
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}
