#include <bits/stdc++.h>
using namespace std;
int find(vector<int>& arr, int n) {
  int res = arr[n - 1];
  int a1 = res, a2;
  for (int i = n - 2; i > -1; i--) {
    if (arr[n - 1] % arr[i] != 0) {
      a2 = arr[i];
      res += a2;
      for (int k = i - 1; k > -1; k--) {
        if (a1 % arr[k] != 0 && a2 % arr[k] != 0) {
          res += arr[k];
          break;
        }
      }
      break;
    }
  }
  return res;
}
int main() {
  int q, n;
  cin >> q;
  while (q--) {
    cin >> n;
    vector<int> arr;
    set<int> myset;
    int t = 0;
    for (int i = 0; i < n; i++) {
      cin >> t;
      if (myset.count(t) > 0) continue;
      myset.insert(t);
      arr.push_back(t);
    }
    int len = arr.size();
    sort(arr.begin(), arr.end());
    int res = find(arr, len);
    if (len >= 2 && arr[len - 2] * 2 == arr[len - 1])
      res = max(res, find(arr, len - 1));
    cout << res << endl;
  }
  return 0;
}
