#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n;
    scanf("%d", &n);
    set<int> s;
    for (int i = 0; i < n; i++) {
      int x;
      scanf("%d", &x);
      s.insert(x);
    }
    vector<int> v(s.begin(), s.end());
    reverse(v.begin(), v.end());
    n = v.size();
    int res = v[0];
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++) {
        if (v[i] % v[j] == 0) continue;
        res = max(res, v[i] + v[j]);
        for (int k = j + 1; k < n; k++)
          if (v[i] % v[k] != 0 and v[j] % v[k] != 0) {
            res = max(res, v[i] + v[j] + v[k]);
            break;
          }
        break;
      }
    printf("%d\n", res);
  }
  return 0;
}
