#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort((a).begin(), (a).end());
  a.resize(unique((a).begin(), (a).end()) - a.begin());
  n = (long long)a.size();
  long long ans = a.back();
  for (long long i = n - 1; i >= 1; i--) {
    for (long long j = i - 1; j >= 0; j--) {
      if (a[i] % a[j] == 0) continue;
      long long s = a[i] + a[j];
      for (long long k = j - 1; k >= 0; k--) {
        if (a[i] % a[k] == 0 or a[j] % a[k] == 0) continue;
        ans = max(ans, s + a[k]);
        break;
      }
      ans = max(ans, s);
      break;
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    solve();
  }
  return 0;
}
