#include <bits/stdc++.h>
using namespace std;
int n, cntn;
int a[200005], p[200005];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) p[i] = i - 1;
    for (int i = 1; i <= n; i++) {
      int cnt = 1, sum = a[i], cur = i;
      while (cnt < 3 && cur) {
        if (a[i] % a[cur]) cnt++, sum += a[cur];
        while (p[cur] && a[i] % a[p[cur]] == 0) p[cur] = p[p[cur]];
        cur = p[cur];
      }
      ans = max(ans, sum);
    }
    printf("%d\n", ans);
  }
  return 0;
}
