#include <bits/stdc++.h>
using namespace std;
const int Nmax = 2e5 + 5;
vector<int> s[Nmax];
int a[Nmax];
int pos[Nmax];
int mx[Nmax];
int n;
void enter() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
}
void build() {
  int N = 0;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[N]) a[++N] = a[i];
  }
  for (int i = N + 1; i <= n; i++) {
    a[i] = 0;
  }
  n = N;
  for (int i = 1; i <= n; i++) {
    s[a[i]].clear();
    for (int j = i - 1; j >= 1; j--) {
      if (a[i] % a[j]) s[a[i]].push_back(a[j]);
      if (s[a[i]].size() > 160) break;
    }
  }
}
void solve() {
  int ans = a[n];
  for (int i = n; i >= 1; i--) {
    if (s[a[i]].size()) ans = max(ans, a[i] + s[a[i]][0]);
    for (int x : s[a[i]]) {
      for (int y : s[x]) {
        if (a[i] + x + y < ans) break;
        if (a[i] % y == 0) continue;
        ans = a[i] + x + y;
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    enter();
    build();
    solve();
  }
  return 0;
}
