#include <bits/stdc++.h>
using namespace std;
int n, t;
vector<int> a, q;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    a.clear();
    for (int i = 1; i <= n; ++i) {
      int x;
      scanf("%d", &x);
      a.push_back(x);
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    reverse(a.begin(), a.end());
    n = a.size();
    int res = -1e9;
    for (int i = 0; i < n; ++i) {
      q.clear();
      q.push_back(a[i]);
      int s = a[i];
      for (int j = i + 1; j < n; ++j) {
        bool cc = 0;
        for (int k = 0; k < q.size(); ++k)
          if (q[k] % a[j] == 0) cc = 1;
        if (cc) continue;
        q.push_back(a[j]);
        s += a[j];
        if ((int)q.size() >= 3) break;
      }
      res = max(res, s);
    }
    printf("%d\n", res);
  }
  return 0;
}
