#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 70;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double eps = 1e-7;
const double PI = acos(-1.0);
int n, m, k;
int a[maxn];
int main() {
  int T;
  cin >> T;
  while (T--) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    n = unique(a, a + n) - a;
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
      ans = max(ans, a[i]);
      for (int j = i - 1; j >= 0 && a[i] + 2 * a[j] > ans; j--) {
        if (a[i] % a[j] == 0) continue;
        ans = max(ans, a[i] + a[j]);
        for (int k = j - 1; k >= 0 && a[i] + a[j] + a[k] > ans; k--) {
          if (a[i] % a[k] == 0 || a[j] % a[k] == 0) continue;
          ans = max(ans, a[i] + a[j] + a[k]);
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
