#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int q;
  cin >> q;
  while (q--) {
    long long int n;
    cin >> n;
    vector<long long int> ar(n);
    for (int x = 0; x < n; x++) cin >> ar[x];
    sort(ar.begin(), ar.end());
    vector<long long int> arr[n + 1];
    long long int mae = ar[ar.size() - 1];
    for (long long int x = 0; x < n; x++) {
      long long int ma = ar[x];
      long long int ind = x;
      for (long long int j = ar[x]; j <= 2 * ar[ar.size() - 1]; j += ar[x]) {
        auto it = lower_bound(ar.begin(), ar.end(), j);
        if (it != ar.begin())
          --it;
        else
          continue;
        if (*it > ma && *it % ar[x] != 0) {
          ma = *it;
          ind = it - ar.begin();
        }
      }
      if (ma != ar[x]) {
        arr[ind].push_back(ar[x]);
        mae = max(ar[ind] + ar[x], mae);
      }
    }
    for (long long int x = 0; x < n; x++) {
      for (long long int i = 0; i < arr[x].size(); i++) {
        long long int ma = arr[x][i];
        for (long long int j = arr[x][i]; j <= 2 * arr[x][arr[x].size() - 1];
             j += arr[x][i]) {
          auto it = lower_bound(arr[x].begin(), arr[x].end(), j);
          if (it != arr[x].begin())
            --it;
          else
            continue;
          if (*it > ma && *it % arr[x][i] != 0) {
            ma = *it;
          }
        }
        if (ma != arr[x][i]) mae = max(ar[x] + ma + arr[x][i], mae);
      }
    }
    cout << mae << endl;
  }
}
