#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      s.insert(a);
    }
    vector<int> v(s.begin(), s.end());
    reverse(v.begin(), v.end());
    n = v.size();
    int ans = v[0];
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (v[i] % v[j] == 0) continue;
        ans = max(ans, v[i] + v[j]);
        for (int k = j + 1; k < n; k++) {
          if (v[i] % v[k] == 0 || v[j] % v[k] == 0) continue;
          ans = max(ans, v[i] + v[j] + v[k]);
          break;
        }
        break;
      }
    }
    cout << ans << "\n";
  }
}
