#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int w33ha() {
  scanf("%d", &n);
  a.clear();
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  int maxn = a[a.size() - 1];
  for (int i = a.size() - 1; i >= 0; i--) {
    for (int j = i - 1; j >= 0; j--) {
      if (j > 0 && a[i] + a[j] + a[j - 1] <= maxn) break;
      if (a[i] % a[j])
        maxn = max(maxn, a[i] + a[j]);
      else
        continue;
      for (int k = j - 1; k >= 0; k--) {
        if (a[i] + a[j] + a[k] <= maxn) break;
        if ((a[i] % a[k]) && (a[j] % a[k])) {
          maxn = a[i] + a[j] + a[k];
          break;
        }
      }
      break;
    }
  }
  printf("%d\n", maxn);
  return 0;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) w33ha();
  return 0;
}
