#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a + 1, a + 1 + n);
    int ans = a[n];
    for (int i = n; i >= 1; i--) {
      if (a[i] * 3 <= ans) break;
      for (int j = i - 1; j >= 1; j--) {
        if (a[j] * 2 + a[i] <= ans) break;
        if (a[i] % a[j] == 0) continue;
        for (int k = j - 1; k >= 1; k--) {
          if (a[k] + a[j] + a[i] <= ans) break;
          if (a[j] % a[k] == 0 || a[i] % a[k] == 0) continue;
          ans = max(a[i] + a[j] + a[k], ans);
          break;
        }
        ans = max(a[i] + a[j], ans);
        while (j >= 2 && a[j - 1] == a[j]) j--;
      }
      while (i >= 2 && a[i - 1] == a[i]) i--;
    }
    printf("%d\n", ans);
  }
  return 0;
}
