#include <bits/stdc++.h>
using namespace std;
int x[200005];
int main() {
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i += 1) {
      cin >> x[i];
    }
    sort(x + 1, x + n + 1);
    n = unique(x + 1, x + n + 1) - x - 1;
    ans = x[n];
    for (int i = n; i > 0; i -= 1) {
      for (int j = i - 1; j > 0; j -= 1) {
        if (x[i] + x[j] + x[j - 1] < ans) {
          break;
        }
        if (x[i] % x[j] == 0) {
          continue;
        }
        ans = max(ans, x[i] + x[j]);
        for (int k = j - 1; k > 0; k -= 1) {
          if (x[i] + x[j] + x[k] < ans) {
            break;
          }
          if (x[i] % x[k] != 0 && x[j] % x[k] != 0) {
            ans = max(ans, x[i] + x[j] + x[k]);
          }
        }
      }
    }
    cout << ans << endl;
  }
}
