#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a, a + n);
    vector<int> l;
    l.push_back(a[0]);
    for (int i = 1; i < n; i++) {
      if (a[i] != a[i - 1]) l.push_back(a[i]);
    }
    n = l.size();
    for (int i = 0; i < n; i++) {
      a[i] = l[i];
    }
    int mx = a[n - 1];
    for (int i = n - 1; i >= 1; i--) {
      if (a[i] + a[i - 1] <= mx) break;
      for (int j = i - 1; j >= 0; j--) {
        if (a[i] + a[j] <= mx) break;
        if (a[i] % a[j]) {
          mx = max(mx, a[i] + a[j]);
          break;
        }
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (i >= 2 && a[i] + a[i - 1] + a[i - 2] <= mx) break;
      for (int j = i - 1; j >= 0; j--) {
        if (j >= 1 && a[i] + a[j] + a[j - 1] <= mx) break;
        if (a[i] % a[j] != 0) {
          mx = max(mx, a[i] + a[j]);
        } else
          continue;
        for (int k = j - 1; k >= 0; k--) {
          if (a[i] + a[j] + a[k] <= mx) break;
          if (a[i] % a[k] != 0 && a[j] % a[k] != 0) {
            mx = max(mx, a[i] + a[j] + a[k]);
            break;
          }
        }
      }
    }
    cout << mx << endl;
  }
}
