#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    unordered_map<int, int> m;
    for (int i = 0; i < n; i++) {
      int te;
      cin >> te;
      m[te]++;
    }
    vector<int> a;
    for (auto i : m) {
      a.push_back(i.first);
    }
    n = a.size();
    sort(a.begin(), a.end(), greater<int>());
    int sum = a[0];
    for (int i = 0; i < n - 1; i++) {
      int ret = 0;
      if (i <= n - 2) ret = a[i] + a[i + 1];
      if (i <= n - 3) {
        ret += a[i + 2];
      }
      if (sum > ret) {
        break;
      }
      sum = max(sum, a[i]);
      for (int j = i + 1; j < n; j++) {
        if (j + 1 < n) {
          if (sum - a[j + 1] > a[i] + a[j]) {
            break;
          }
        }
        if (a[i] % a[j] != 0) {
          sum = max(sum, a[i] + a[j]);
          for (int k = j + 1; k < n; k++) {
            if (a[i] % a[k] != 0 && a[j] % a[k] != 0) {
              sum = max(sum, a[i] + a[j] + a[k]);
              break;
            }
          }
        }
      }
    }
    cout << sum << endl;
  }
}
