#include <bits/stdc++.h>
using namespace std;
int q, n, x;
void f() {
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  int maxi = v.back();
  for (int i = v.size() - 1; i > 0 && v[i] + v[i - 1] > maxi; i--)
    for (int j = i - 1; j >= 0; j--)
      if (v[i] % v[j] != 0) {
        maxi = max(maxi, v[i] + v[j]);
        break;
      }
  for (int i = v.size() - 1; i > 0 && v[i] + v[i - 1] + v[i - 2] > maxi; i--)
    for (int j = i - 1; j > 0; j--)
      if (v[i] % v[j] != 0)
        for (int k = j - 1; k >= 0; k--)
          if (v[i] % v[k] != 0 && v[j] % v[k] != 0) {
            maxi = max(maxi, v[i] + v[j] + v[k]);
            break;
          }
  cout << maxi << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> q;
  for (int u = 0; u < q; u++) f();
  return 0;
}
