#include <bits/stdc++.h>
using namespace std;
const long long LINF = 4e18;
const int INF = 1e9 + 7;
int solution() {
  int n;
  cin >> n;
  int m[n];
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }
  sort(m, m + n);
  reverse(m, m + n);
  int a = m[0];
  int b, c;
  b = c = 0;
  for (int i = 0; i < n; i++) {
    if (a % m[i]) {
      b = m[i];
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (b && a % m[i] && b % m[i]) {
      c = m[i];
      break;
    }
  }
  int a1, b1, c1;
  a1 = b1 = c1 = 0;
  for (int i = 0; i < n; i++) {
    if (!(a % 2) && m[i] == a / 2) {
      a1 = m[i];
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (!(a % 3) && m[i] == a / 3) {
      b1 = m[i];
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (!(a % 5) && m[i] == a / 5) {
      c1 = m[i];
      break;
    }
  }
  return max(a + b + c, a1 + b1 + c1);
}
signed main() {
  int q;
  cin >> q;
  vector<int> ans;
  while (q--) {
    int x = solution();
    ans.push_back(x);
  }
  for (int x : ans) {
    cout << x << endl;
  }
  return 0;
}
