#include <bits/stdc++.h>
using namespace std;
void inp() {}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
long long int n, m, a[200001], temp, b, k, pos, flag = 0, t, temp1, temp2,
                                                temp3, ans, num, sum = 0;
vector<long long int> v, v1, v2;
vector<pair<long long int, long long int> > vp1, vp2;
long long int find(long long int a[], long long int g) {
  long long int count = 0;
  long long int r1 = 0, r2 = 0, r3 = 0;
  for (long long int i = g; i >= 0; i--) {
    if (count == 0) {
      r1 = a[g];
      count++;
    } else if (count == 1) {
      if (r1 % a[i] == 0)
        continue;
      else {
        count++;
        r2 = a[i];
      }
    } else if (count == 2) {
      if (r1 % a[i] != 0 && r2 % a[i] != 0) {
        count++;
        r3 = a[i];
        break;
      }
    }
  }
  return r1 + r2 + r3;
}
int main() {
  inp();
  fast();
  cin >> t;
  for (long long int j = 0; j < t; j++) {
    cin >> n;
    for (long long int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long int pos1 = -1, pos2 = -1;
    long long int max1 = 0;
    for (long long int i = n - 1; i >= 0; i--) {
      if (a[i] != a[n - 1]) {
        max1 = a[i];
        pos1 = i;
        break;
      }
    }
    for (long long int i = n - 1; i >= 0; i--) {
      if (a[i] != a[n - 1] && a[i] != max1) {
        pos2 = i;
        break;
      }
    }
    if (n >= 3) {
      temp1 = find(a, n - 1);
      temp2 = find(a, pos1);
      temp3 = find(a, pos2);
      ans = max(temp1, max(temp2, temp3));
      cout << ans << "\n";
    } else if (n == 2) {
      if (a[1] % a[0] == 0)
        cout << a[1] << "\n";
      else
        cout << a[1] + a[0] << "\n";
    } else {
      cout << a[0] << "\n";
    }
  }
}
