#include <bits/stdc++.h>

using namespace std;

//#define int long long

typedef long long ll;
typedef long double ld;

void solve() {
    set<ll> used;
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for (auto elem : a) {
        ll k = 1;
        while (used.find(k * elem) != used.end()) ++k;
        used.insert(k * elem);
    }
    cout << *used.rbegin() << "\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LC
    freopen("/home/team11/CLionProjects/contest/input.txt", "r", stdin);
    freopen("/home/team11/CLionProjects/contest/output.txt", "w", stdout);

#endif
    int t= 1 ;
    cin >> t;
    for (int tt =0; tt <t; tt++) {
        solve();
    }
    return 0;
}