#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const int maxn = 2e5 + 10;
int arr[maxn];
set<int, greater<int>> se;
bool test235(int top) {
  if (top % 30) return false;
  return se.count(top / 2) && se.count(top / 3) && se.count(top / 5);
}
int solve_two() {
  if (se.begin() == se.end()) {
    return 0;
  }
  int top = *se.begin();
  int ans = top;
  se.erase(se.begin());
  for (auto val : se) {
    if (top % val) {
      ans += val;
      break;
    }
  }
  return ans;
}
int main() {
  int round;
  scanf("%d", &round);
  while (round--) {
    int n;
    scanf("%d", &n);
    se.clear();
    for (int i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      se.insert(x);
    }
    int top = *se.begin();
    int ans = solve_two();
    if (test235(top)) {
      ans = max(ans, top / 2 + top / 3 + top / 5);
    }
    for (int i = 1; i * i <= top; i++) {
      if (top % i == 0) {
        se.erase(i);
        se.erase(top / i);
      }
    }
    ans = max(ans, solve_two() + top);
    printf("%d\n", ans);
  }
}
