#include <bits/stdc++.h>
const int MAXN = 2e5 + 5;
int a[MAXN], n;
inline void Solve() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i) scanf("%d", a + i);
  int ans = 0;
  std::sort(a + 1, a + n + 1);
  std::reverse(a + 1, a + n + 1);
  n = std::unique(a + 1, a + n + 1) - a - 1;
  for (register int i = 1; i <= n; ++i) {
    int t = a[i], tt = 0, ts = 1;
    for (register int j = i + 1; j <= n; ++j) {
      if (ts == 1 && t % a[j]) {
        ts++;
        t += a[j], tt = a[j];
      } else {
        if (ts == 2 && a[i] % a[j] && tt % a[j]) {
          ts++;
          t += a[j];
          break;
        }
      }
    }
    ans = std::max(ans, t);
  }
  printf("%d\n", ans);
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) Solve();
  return 0;
}
