#include <bits/stdc++.h>
using namespace std;
const int C = 1e6;
const int mxn = 2e6;
int get() {
  int n;
  cin >> n;
  return n;
}
void trace(string i) {}
void vtrace(vector<int> i) {}
int process(vector<int>& a) {
  int n = a.size();
  int sum = a.back();
  int md;
  for (int i = n - 2; i > -1; i--) {
    md = a[i];
    if (a.back() % a[i] != 0) {
      sum += a[i];
      break;
    }
  }
  for (int i = n - 2; i > -1; i--) {
    if (md % a[i] && a.back() % a[i]) {
      sum += a[i];
      break;
    }
  }
  return sum;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) cin >> x;
  sort((a).begin(), (a).end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  int sum = INT_MIN;
  for (int i = 0; i <= 1; i++) {
    sum = max(sum, process(a));
    if (a.size() == 1) break;
    a.pop_back();
  }
  cout << sum;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n = 1;
  cin >> n;
  while (n--) {
    solve();
    cout << '\n';
  }
  return 0;
}
