#include <bits/stdc++.h>
using namespace std;
int q, m, n, res, a[200005], b[200005], f[200005];
int main() {
  cin >> q;
  while (q--) {
    cin >> n;
    m = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    res = a[n];
    for (int i = 1; i <= n; i++)
      if (a[i] != a[i - 1]) b[++m] = a[i];
    for (int i = 1; i <= m; i++) f[i] = 0;
    for (int i = 1; i <= m; i++)
      for (int j = i - 1; j >= 1; j--)
        if (b[i] % b[j]) {
          f[i] = j;
          break;
        }
    for (int i = m; i >= 1; i--) {
      res = max(res, b[i] + b[f[i]]);
      for (int j = f[f[i]]; j >= 1; j--)
        if (b[i] % b[j] && b[f[i]] % b[j]) {
          res = max(res, b[i] + b[f[i]] + b[j]);
          break;
        }
    }
    cout << res << "\n";
  }
  return 0;
}
