#include <bits/stdc++.h>
using namespace std;
string char_to_str(char c) {
  string tem(1, c);
  return tem;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t) {
    --t;
    long long n;
    cin >> n;
    long long ans = 0;
    set<long long> s;
    for (long long i = 0; i < n; ++i) {
      long long d;
      cin >> d;
      s.insert(d);
    }
    vector<long long> v;
    for (auto r : s) {
      v.push_back(r);
    }
    for (long long i = 0; i < v.size(); ++i) {
      long long va = v[i];
      long long j;
      for (j = i - 1; j >= 0; --j) {
        if (v[i] % v[j] != 0) break;
      }
      if (j == -1) {
        ans = max(ans, va);
        continue;
      }
      long long k = j - 1;
      for (; k >= 0; --k) {
        if (v[j] % v[k] != 0 && v[i] % v[k] != 0) {
          break;
        }
      }
      if (k == -1) {
        ans = max(ans, va + v[j]);
      } else {
        ans = max(ans, va + v[j] + v[k]);
      }
    }
    cout << ans << "\n";
  }
}
