#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
template <typename T>
inline long long squ(T x) {
  return (long long)x * x;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline T read() {
  T cur = 0, flag = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') flag = -1;
  for (; isdigit(c); c = getchar()) cur = (cur << 3) + (cur << 1) + (c ^ 0x30);
  return flag * cur;
}
const int maxn = 2e5 + 10;
const int N = 2001;
const int limit = 2e6;
const long long mod = 1e9 + 7;
int q, n, w;
int main() {
  scanf("%d", &q);
  for (register int i = 1; i <= q; ++i) {
    set<int> st;
    scanf("%d", &n);
    for (register int i = 1; i <= n; ++i) {
      scanf("%d", &w);
      st.insert(w);
    }
    int mx = *st.rbegin();
    int res = 0;
    if (mx % 2 == 0 && mx % 3 == 0 && mx % 5 == 0) {
      if (st.count(mx / 2) && st.count(mx / 3) && st.count(mx / 5)) {
        res = max(res, mx / 2 + mx / 3 + mx / 5);
      }
    }
    vector<int> cur;
    while (!st.empty() && int(cur.size()) < 3) {
      int x = *st.rbegin();
      st.erase(prev(st.end()));
      bool flag = true;
      for (auto k : cur) flag &= (k % x != 0);
      if (flag) cur.emplace_back(x);
    }
    res = max(res, accumulate(cur.begin(), cur.end(), 0));
    printf("%d\n", res);
  }
  return 0;
}
