#include <bits/stdc++.h>
using namespace std;
long long datas[1001000];
bool vis[210000] = {false};
int main() {
  ios::sync_with_stdio(false);
  long long q;
  long long n;
  cin >> q;
  while (q--) {
    long long ans = 0;
    cin >> n;
    memset(vis, false, sizeof(vis));
    for (long long i = 0; i < n; i++) {
      cin >> datas[i];
      vis[datas[i]] = true;
    }
    sort(datas, datas + n, greater<long long>());
    long long inx = 0;
    ans = datas[0];
    if (datas[0] % 2 == 0 && vis[datas[0] / 2])
      if (datas[0] % 3 == 0 && vis[datas[0] / 3])
        if (datas[0] % 5 == 0 && vis[datas[0] / 5]) {
          ans = datas[0] / 2 + datas[0] / 3 + datas[0] / 5;
        }
    long long sum = 0;
    vis[1] = false;
    for (long long i = 0; i < n; i++) {
      if (!vis[datas[i]]) continue;
      sum += datas[i];
      inx++;
      if (inx == 3) break;
      for (long long j = 1; j <= sqrt(datas[i] * 1.0); j++) {
        if (datas[i] % j == 0) {
          vis[j] = false;
          vis[datas[i] / j] = false;
        }
      }
    }
    cout << max(ans, sum) << endl;
  }
  return 0;
}
