#include <bits/stdc++.h>
using namespace std;
long long Mod(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
class Triplet {
 public:
  long long x;
  long long y;
  long long gcd;
};
Triplet extendedEuclid(long long a, long long b) {
  if (b == 0) {
    Triplet ans;
    ans.gcd = a;
    ans.x = 1;
    ans.y = 0;
    return ans;
  }
  Triplet smallAns = extendedEuclid(b, a % b);
  Triplet ans;
  ans.gcd = smallAns.gcd;
  ans.x = smallAns.y;
  ans.y = smallAns.x - (a / b) * smallAns.y;
  return ans;
}
long long mmInverse(long long a, long long m) {
  Triplet ans = extendedEuclid(a, m);
  return ans.x;
}
bool tell(long long a, long long b) {
  if (a % b == 0) {
    return true;
  }
  if (b % a == 0) {
    return true;
  }
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    long long arr[n];
    set<long long> st;
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
      st.insert(arr[i]);
    }
    vector<long long> v;
    for (auto it : st) {
      v.push_back(it);
    }
    n = v.size();
    long long x = 0;
    for (auto it : v) {
      arr[x++] = it;
    }
    sort(arr, arr + n, greater<long long>());
    long long maxi = -1;
    for (long long i = 0; i < n; i++) {
      if (arr[i] + arr[i + 1] + arr[i + 2] <= maxi) break;
      maxi = max(maxi, arr[i]);
      for (long long j = i + 1; j < n; j++) {
        if (tell(arr[i], arr[j])) {
          continue;
        }
        if (j < n - 1 && arr[i] + arr[j + 1] + arr[j] <= maxi) {
          break;
        }
        maxi = max(maxi, arr[i] + arr[j]);
        for (long long y = j + 1; y < n; y++) {
          if (tell(arr[y], arr[j])) {
            continue;
          } else if (tell(arr[y], arr[i])) {
            continue;
          }
          maxi = max(maxi, arr[i] + arr[y] + arr[j]);
          break;
        }
      }
    }
    cout << maxi << endl;
  }
}
