#include <bits/stdc++.h>
using namespace std;
int n, q, a[200010], big[4], chk[200010];
int main() {
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &n);
    int ans = 0, idx = 1;
    for (int j = 0; j < n; j++) scanf("%d", a + j), chk[a[j]]++;
    sort(a, a + n);
    big[1] = 0, big[2] = 0, big[3] = 0;
    big[1] = a[n - 1];
    if (big[1] % 30 == 0 && chk[big[1] / 2] && chk[big[1] / 3] &&
        chk[big[1] / 5])
      ans = max(ans, big[1] / 2 + big[1] / 3 + big[1] / 5);
    for (int i = n - 2; i >= 0; i--) {
      bool flag = 0;
      if (idx == 3) break;
      for (int j = 1; j <= idx; j++)
        if (big[j] % a[i] == 0) flag = 1;
      if (flag) continue;
      idx++;
      big[idx] = a[i];
    }
    ans = max(ans, big[1] + big[2] + big[3]);
    for (int j = 0; j < n; j++) chk[a[j]]--;
    printf("%d\n", ans);
  }
  return 0;
}
