#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 1001001001;
const int MAX = 1e5 + 5;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    set<ll> st;
    for (int i = 0; i < n; i++) {
      ll a;
      cin >> a;
      st.insert(a);
    }
    ll ans = 0;
    ll mx = *st.rbegin();
    if (mx % 2 == 0 && mx % 3 == 0 && mx % 5 == 0) {
      if (st.count(mx / 2) && st.count(mx / 3) && st.count(mx / 5))
        ans = mx / 2 + mx / 3 + mx / 5;
    }
    vector<ll> res;
    while (!st.empty() && res.size() < 3) {
      ll x = *st.rbegin();
      st.erase(prev(st.end()));
      bool ok = true;
      for (ll k : res)
        if (k % x == 0) ok = false;
      if (ok) res.push_back(x);
    }
    ll tmp = 0;
    for (int i = 0; i < res.size(); i++) {
      tmp += res[i];
    }
    cout << max(tmp, ans) << endl;
  }
}
