#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10, INF = 2147483647;
int a[MAXN];
int main() {
  int T, n, i, res = 0;
  scanf("%d", &T);
  while (T--) {
    res = 0;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    int ed = a[n];
    res = a[n];
    bool f2 = 0, f3 = 0, f5 = 0;
    for (i = 1; i <= n; i++) {
      if (a[i] * 2 == ed) f2 = true;
      if (a[i] * 3 == ed) f3 = true;
      if (a[i] * 5 == ed) f5 = true;
    }
    if (f2 && f3 && f5) res = max(res, ed / 2 + ed / 3 + ed / 5);
    for (i = 1; i <= n; i++)
      if (a[n] % a[i] == 0) a[i] = INF;
    sort(a + 1, a + n + 1);
    while (a[n] == INF) n--;
    res = max(res, ed + a[n]);
    for (i = n - 1; i >= 1; i--)
      if (a[n] % a[i] != 0) {
        res = max(res, ed + a[n] + a[i]);
        break;
      }
    printf("%d\n", res);
  }
  return 0;
}
