#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7, M = 6e1;
int arr[N], n, q;
vector<int> pos[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
      pos[i].clear();
    }
    sort(arr, arr + n);
    n = unique(arr, arr + n) - arr;
    for (int i = 0; i < n; ++i) {
      int cnt = 0;
      for (int j = i; j >= 0 && cnt < M; --j) {
        if (arr[i] % arr[j]) {
          pos[i].push_back(j);
          cnt++;
        }
      }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
      res = max(res, arr[i]);
      if (pos[i].size()) {
        int j = pos[i][0];
        res = max(res, arr[i] + arr[j]);
        for (auto k : pos[j]) {
          if (arr[i] % arr[k]) {
            res = max(res, arr[i] + arr[j] + arr[k]);
          }
        }
      }
    }
    cout << res << "\n";
  }
  return 0;
}
