#include <bits/stdc++.h>
using namespace std;
template <class FR>
inline FR max(FR &a, const FR &b) {
  return (a > b) ? a : b;
}
template <class FR>
inline FR min(FR &a, const FR &b) {
  return (a > b) ? b : a;
}
const long long MAXN = (int)1e6 + 10;
const long long MOD = 1e9 + 7;
const long long INF = 998244353;
bool comp(string a, string b) { return a.size() > b.size(); }
int main() {
  ios_base::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      v.push_back(x);
    }
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()) - v.begin());
    n = v.size();
    int ans = v[n - 1];
    for (int i = 0; i < n; i++) {
      for (int j = i - 1; j >= 0; j--) {
        if (v[i] % v[j] == 0) {
          continue;
        }
        ans = max(v[i] + v[j], ans);
        for (int k = j - 1; k >= 0; k--) {
          if (v[j] % v[k] == 0 || v[i] % v[k] == 0) {
            continue;
          }
          ans = max(v[i] + v[j] + v[k], ans);
          break;
        }
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
