#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int mxN = 2e5 + 5;
template <class T>
T gcd(T a, T b) {
  return ((b == 0) ? a : gcd(b, a % b));
}
void solve() {
  int n;
  cin >> n;
  vector<int> b(n), a;
  int mx = 0;
  for (int i = 0; i < (int)(n); i++) cin >> b[i], mx = max(mx, b[i]);
  sort(b.begin(), b.end());
  for (int i = 0; i < (int)(n); i++)
    if (!i || (i && b[i] != b[i - 1])) a.push_back(b[i]);
  n = a.size();
  for (int i = 0; i < (int)(n); i++) {
    vector<int> st;
    for (int j = i - 1; j >= 0; j--) {
      if (a[i] % a[j] != 0) {
        for (int k = 0; k < (int)(st.size()); k++) {
          if (st[k] % a[j] != 0) {
            mx = max(mx, a[i] + st[k] + a[j]);
            if (!k) goto end;
          }
        }
        mx = max(mx, a[i] + a[j]);
        st.push_back(a[j]);
      }
    }
  end:;
  }
  cout << mx << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
