#include <bits/stdc++.h>
using namespace std;
int T, n, nb, i, j, k;
int a[400005], b[400005];
int ans, upd;
int main() {
  scanf("%d", &T);
  while (T--) {
    n = 0;
    scanf("%d", &nb);
    for (i = 1; i <= nb; i++) {
      scanf("%d", &b[i]);
    }
    sort(b + 1, b + 1 + nb);
    b[nb + 1] = 0;
    for (i = 1; i <= nb; i++) {
      if (b[i] != b[i + 1]) {
        a[++n] = b[i];
      }
    }
    ans = a[n];
    for (i = n; i >= max(n - 300, 1); i--) {
      for (j = i - 1; j >= max(n - 300, 1); j--) {
        if (a[i] % a[j] == 0) continue;
        ans = max(ans, a[i] + a[j]);
        break;
      }
    }
    for (i = n; i >= max(n - 300, 1); i--) {
      for (j = i - 1; j >= max(n - 300, 1); j--) {
        for (k = j - 1; k >= max(n - 300, 1); k--) {
          if ((a[i] % a[j] == 0) || (a[i] % a[k] == 0) || (a[j] % a[k] == 0))
            continue;
          ans = max(ans, a[i] + a[j] + a[k]);
          break;
        }
      }
    }
    printf("%d\n", ans);
  }
}
