#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 2e5 + 10;
long long q, n, ans;
long long Arr[MAX_N];
int nxt[MAX_N];
vector<int> vec;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> q;
  while (q--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> Arr[i];
    sort(Arr, Arr + n);
    n = unique(Arr, Arr + n) - Arr;
    ans = Arr[n - 1];
    for (int i = n - 1; ~i; i--) {
      for (int j = n - 1; i < j; j--)
        if (Arr[j] % Arr[i]) {
          ans = max(ans, Arr[i] + Arr[j]);
          break;
        }
    }
    int ind = n;
    for (int i = n - 1; ~i; i--) {
      vec.clear();
      int find = 0;
      for (int j = n - 1; i < j; j--)
        if (Arr[j] % Arr[i]) {
          vec.push_back(j);
          for (int t = 0; t < vec.size() - 1; t++)
            if (Arr[vec[t]] % Arr[j]) {
              ans = max(ans, Arr[i] + Arr[j] + Arr[vec[t]]);
              find++;
              break;
            }
          if (find >= 110) break;
        }
    }
    cout << ans << "\n";
  }
  return 0;
}
