#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
int num[maxn], cnt, fa[maxn], ans;
set<int> se;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, ans = 0;
    cnt = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      se.insert(x);
    }
    for (set<int>::iterator it = se.begin(); it != se.end(); it++)
      num[++cnt] = *it;
    se.clear();
    for (int i = cnt; i >= 1; i--) {
      ans = max(ans, num[i]);
      for (int j = cnt; j > i; j--)
        if (num[j] % num[i] != 0) {
          ans = max(ans, num[i] + num[j]);
          for (int k = j - 1; k > i; k--)
            if (num[j] % num[k] != 0 && num[k] % num[i] != 0) {
              ans = max(ans, num[i] + num[j] + num[k]);
              break;
            }
          break;
        }
    }
    printf("%d\n", ans);
  }
  return 0;
}
