#include <bits/stdc++.h>
using namespace std;
bool has[200009];
int left[200009];
int main() {
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    int N;
    cin >> N;
    vector<int> v;
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int res = v[0];
    vector<int> w;
    vector<int> t;
    for (int i = 1; i < v.size(); i++)
      if (v[i] != v[i - 1]) {
        if (v[0] % v[i] != 0)
          w.push_back(v[i]);
        else
          t.push_back(v[i]);
      }
    if (w.size() > 0) {
      res += w[0];
      for (int i = 1; i < w.size(); i++)
        if (w[0] % w[i] != 0) {
          res += w[i];
          break;
        }
    }
    if (t.size() >= 3 && t[0] + t[1] + t[2] > res) {
      if (t[0] % t[1] != 0 && t[1] % t[2] != 0 && t[0] % t[2] != 0)
        res = t[0] + t[1] + t[2];
    }
    if (t.size() >= 4 && t[0] + t[1] + t[3] > res) {
      if (t[0] % t[1] != 0 && t[1] % t[3] != 0 && t[0] % t[3] != 0)
        res = t[0] + t[1] + t[3];
    }
    cout << res << "\n";
  }
  return 0;
}
