#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int Q;
  cin >> Q;
  while (Q--) {
    int n;
    cin >> n;
    set<int> S;
    int best = 0;
    vector<int> arr(n);
    for (auto &a : arr) {
      cin >> a;
      best = max(best, a);
    }
    int best2 = 0;
    bool b1 = false, b2 = false, b3 = false;
    for (auto a : arr) {
      if (best % 2 == 0 and a == best / 2) b1 = true;
      if (best % 3 == 0 and a == best / 3) b2 = true;
      if (best % 5 == 0 and a == best / 5) b3 = true;
      if (best % a) {
        S.insert(a);
        best2 = max(best2, a);
      }
    }
    if (best2) S.erase(S.find(best2));
    int best3 = 0;
    for (auto s : S) {
      if (best % s and best2 % s) {
        best3 = max(s, best3);
      }
    }
    int s1 = best + best2 + best3;
    int s2 = 0;
    if (b1 and b2 and b3) s2 = best / 2 + best / 3 + best / 5;
    cout << max(s1, s2) << endl;
  }
  return 0;
}
