#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    n = a.size();
    int ans = a.back();
    for (int i = n - 1; i >= 0; i--) {
      if (i >= 2) {
        if (ans > a[i] + a[i - 1] + a[i - 2]) break;
      }
      for (int j = i - 1; j >= 0; j--) {
        if (j >= 1) {
          if (ans > a[i] + a[j] + a[j - 1]) break;
        }
        if (a[i] % a[j]) {
          ans = max(ans, a[i] + a[j]);
          for (int k = j - 1; k >= 0; k--) {
            if (ans > a[i] + a[j] + a[k]) break;
            if ((a[i] % a[k]) && (a[j] % a[k])) {
              ans = max(ans, a[i] + a[j] + a[k]);
              break;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
