#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  int c = getchar(), f = 1;
  for (; !isdigit(c); c = getchar())
    if (c == 45) f = -1;
  for (; isdigit(c); c = getchar()) (x *= 10) += f * (c - '0');
}
int n, a[200000 + 5];
int main() {
  int T;
  read(T);
  while (T--) {
    read(n);
    set<int> s;
    for (int i = 1; i <= n; i++) read(a[i]), s.insert(a[i]);
    sort(a + 1, a + n + 1);
    int s1 = 0, s2 = 0;
    if (a[n] % 2 == 0 && a[n] % 3 == 0 && a[n] % 5 == 0)
      if (s.count(a[n] / 2) && s.count(a[n] / 3) && s.count(a[n] / 5))
        s1 = a[n] / 30 * 31;
    vector<int> ans;
    for (int i = n; i; i--) {
      bool flag = true;
      for (int x : ans)
        if (x % a[i] == 0) flag = false;
      if (flag) ans.push_back(a[i]);
      if ((int)ans.size() == 3) break;
    }
    for (int x : ans) s2 += x;
    printf("%d\n", max(s1, s2));
  }
  return 0;
}
