#include <bits/stdc++.h>
using namespace std;
typedef int intarr[200007];
intarr so, res;
int T, N;
void Compress() {
  sort(so, so + N, greater<int>());
  int unq = so[0], M = N;
  for (int i = 1; i < N; ++i) {
    if (so[i] == unq)
      so[i] = 0, --M;
    else
      unq = so[i];
  }
  sort(so, so + N, greater<int>());
  N = M;
}
int Solve() {
  Compress();
  int s1, s2 = so[0] + 1, res = so[0], sum, vt1 = N, vt2, limit = N - 1,
          len = 1;
  for (int i = 0; i < limit; ++i) {
    len = 1, sum = so[i];
    if (!(so[i] % s2)) continue;
    for (int j = i + 1; j < vt1; ++j) {
      if (len == 1) {
        if (so[i] % so[j]) {
          vt2 = j;
          sum += so[j];
          res = max(res, sum);
          ++len;
        }
      } else {
        if (so[i] % so[j] && so[vt2] % so[j]) {
          s2 = so[j];
          sum += so[j];
          limit = j + 1;
          vt1 = j + 1;
          res = max(res, sum);
          continue;
        }
      }
    }
  }
  return res;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) scanf("%d", &so[i]);
    printf("%d\n", Solve());
  }
}
