#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 50;
int arr[MAXN], n;
int ST[MAXN], T[MAXN];
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') flag = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 3) + (x << 1) + ch - '0';
  return x * flag;
}
int main() {
  int Q;
  cin >> Q;
  for (int v = 1; v <= Q; v++) {
    n = read();
    for (int i = 1; i <= n; i++) arr[i] = read(), ST[arr[i]] = arr[i];
    sort(arr + 1, arr + 1 + n);
    int Ans = arr[n], Max = arr[n];
    int f2 = 0, f3 = 0, f5 = 0;
    if (Max % 5 == 0 && ST[Max / 5] != 0) f5 = 1;
    if (Max % 3 == 0 && ST[Max / 3] != 0) f3 = 1;
    if (Max % 2 == 0 && ST[Max / 2] != 0) f2 = 1;
    if (f2 && f3 && f5) Ans = max(Ans, Max / 5 + Max / 3 + Max / 2);
    for (int i = 1; i <= n; i++) {
      T[i] = arr[i];
      if (arr[n] % T[i]) Ans = max(Ans, arr[n] + T[i]);
    }
    for (int i = 1; i <= n; i++)
      if (Max % T[i] == 0) T[i] = 2e9;
    int M = 0;
    for (int i = 1; i <= n; i++)
      if (T[i] != 2e9) M = max(M, T[i]);
    for (int i = 1; i <= n; i++)
      if (M % T[i] != 0 && T[i] != 2e9) Ans = max(Ans, Max + M + T[i]);
    cout << Ans << endl;
    for (int i = 1; i <= n; i++) ST[arr[i]] = 0;
  }
  return 0;
}
