#include <bits/stdc++.h>
using namespace std;
int t, n, a[200005], p[200005];
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
      p[i] = i - 1;
    }
    int sum, cnt, x, ans = 0;
    for (int i = 1; i <= n; i++) {
      sum = a[i], cnt = 1, x = i;
      while (cnt < 3 && x >= 1) {
        if (a[i] % a[x]) cnt++, sum += a[x];
        while (p[x] && a[i] % a[p[x]] == 0) p[x] = p[p[x]];
        x = p[x];
      }
      ans = max(ans, sum);
    }
    cout << ans << endl;
  }
  return 0;
}
