#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    set<long long> s;
    for (long long i = 0; i < n; i++) {
      long long x;
      cin >> x;
      s.insert(x);
    }
    vector<long long> vec(s.begin(), s.end());
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    long long res = 0;
    for (long long i = 0; i < 3; i++) {
      vector<long long> chosen;
      for (long long j = i; j < s.size(); j++) {
        if (!chosen.empty() && chosen.size() == 3) break;
        bool flag = false;
        for (long long x : chosen) {
          if (x % vec[j] == 0) {
            flag = true;
            break;
          }
        }
        if (!flag) chosen.push_back(vec[j]);
      }
      long long sum = 0;
      for (long long x : chosen) sum += x;
      res = max(res, sum);
    }
    cout << res << '\n';
  }
}
