#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
int find_ceil(int start, int end, int key) {
  while (start <= end) {
    int mid = (start + end) / 2;
    if (arr[mid] >= key) {
      start = mid + 1;
    } else {
      end = mid - 1;
    }
  }
  return start - 1;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    arr.clear();
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      int x;
      scanf("%d", &x);
      arr.push_back(x);
    }
    sort(arr.begin(), arr.end());
    vector<int>::iterator it;
    it = unique(arr.begin(), arr.end());
    arr.resize(distance(arr.begin(), it));
    n = arr.size();
    int maxi = arr[n - 1];
    for (int i = n - 1; i >= 1; i--) {
      int first = arr[i];
      if (3 * first <= maxi) break;
      for (int j = i - 1; j >= 0; j--) {
        int second = arr[j];
        if (first + 2 * second <= maxi) break;
        if (first % second == 0) continue;
        maxi = max(maxi, first + second);
        for (int k = j - 1; k >= 0; k--) {
          int third = arr[k];
          if (first + second + third <= maxi) break;
          if (first % third == 0 || second % third == 0) continue;
          maxi = max(maxi, first + second + third);
          break;
        }
      }
    }
    printf("%d\n", maxi);
  }
  return 0;
}
