#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], n;
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n);
    n = unique(a + 1, a + 1 + n) - a - 1;
    int ans = a[n];
    for (int i = n; i; i--) {
      if (a[i] * 3 <= ans) break;
      for (int j = i - 1; j; j--) {
        if (a[j] * 2 + a[i] <= ans) break;
        if (a[i] % a[j] == 0) continue;
        ans = max(ans, a[i] + a[j]);
        for (int k = j - 1; k; k--) {
          if (a[i] + a[j] + a[k] <= ans) break;
          if (a[i] % a[k] == 0 || a[j] % a[k] == 0) continue;
          ans = max(ans, a[i] + a[j] + a[k]);
        }
      }
    }
    cout << ans << '\n';
  }
}
