#include <bits/stdc++.h>
using namespace std;
const int LEN = (int)2e5;
int q, n;
int a[LEN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> q;
  while (q--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    vector<int> ans, ans1;
    ans.push_back(a[0]);
    for (int i = 1; i < n && (ans.size() < 3 || ans1.size() < 3); i++) {
      bool f = true;
      for (auto x : ans)
        if (x % a[i] == 0) f = false;
      if (f && ans.size() < 3)
        ans.push_back(a[i]);
      else if (!f && ans1.size() < 3) {
        f = a[i] != ans[0];
        for (auto x : ans1)
          if (x % a[i] == 0) f = false;
        if (f) ans1.push_back(a[i]);
      }
    };
    ;
    ;
    ;
    ;
    ;
    int sum = 0, sum1 = 0;
    for (auto i : ans) sum += i;
    for (auto j : ans1) sum1 += j;
    cout << max(sum, sum1) << "\n";
  }
  return 0;
}
