#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    int sum = a.back();
    n = int(a.size());
    for (int i = n - 1; i >= 1 && a[i] + a[i - 1] > sum; --i) {
      for (int j = i - 1; j >= 0 && a[i] + a[j] > sum; --j) {
        if (a[i] % a[j] == 0) continue;
        sum = max(sum, a[i] + a[j]);
      }
    }
    for (int i = n - 1; i >= 2 && a[i] + a[i - 1] + a[i - 2] > sum; --i) {
      for (int j = i - 1; j >= 1 && a[i] + a[j] + a[j - 1] > sum; --j) {
        if (a[i] % a[j] == 0) continue;
        for (int k = j - 1; k >= 0 && a[i] + a[j] + a[k] > sum; --k) {
          if (a[i] % a[k] != 0 && a[j] % a[k] != 0)
            sum = max(sum, a[i] + a[j] + a[k]);
        }
      }
    }
    cout << sum << '\n';
  }
  return 0;
}
