#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; i++) {
      cin >> v[i];
    }
    sort(v.begin(), v.end());
    long long m = v[n - 1];
    long long ans = 0;
    if (m % 2 == 0 && m % 3 == 0 && m % 5 == 0) {
      if (binary_search(v.begin(), v.end(), m / 2) &&
          binary_search(v.begin(), v.end(), m / 5) &&
          binary_search(v.begin(), v.end(), m / 3)) {
        ans = m / 3 + m / 5 + m / 2;
      }
    }
    long long temp = m;
    long long tt = -1;
    for (long long i = 0; i < n - 1; i++) {
      if (temp % v[i] != 0) {
        tt = v[i];
      }
    }
    if (tt == -1) {
      cout << max(ans, temp);
    } else {
      long long ttt = -1;
      for (long long i = 0; v[i] < tt; i++) {
        if (temp % v[i] != 0 && tt % v[i] != 0) {
          ttt = v[i];
        }
      }
      if (ttt == -1) {
        cout << max(ans, temp + tt);
      } else {
        cout << max(ans, temp + tt + ttt);
      }
    }
    cout << "\n";
  }
}
