#include <bits/stdc++.h>
using namespace std;

const int DIM = 10005;

int l[DIM], r[DIM];
bool viz[DIM];
vector<int> v[DIM];
using ll = long long;

bool cuplaj(int nod) {
    if (viz[nod])
        return false;

    viz[nod] = true;
    for (auto it : v[nod]) {
        if (!l[it]) {
            l[it] = nod;
            r[nod] = it;
            return true;
        }
    }

    for (auto it : v[nod]) {
        if (cuplaj(l[it])) {
            l[it] = nod;
            r[nod] = it;
            return true;
        }
    }

    return false;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    sort(a.begin() + 1, a.end());

    vector<int> mul(n + 1, 1);
    set<ll> s;
    map<ll, int> f;
    int nr = 0;
    for (int i = 1; i <= n; ++i) {
        s.insert(a[i] * 1);
        v[i].clear();
        l[i] = r[i] = 0;
        mul[i] = 1;
    }

    int dim = 0;
    ll mx = 0;
    vector<int> mark(n + 1, 0);
    while (1) {
        // std::cerr << dim << endl;
        ll val = *s.begin();
        s.erase(s.begin());
        // std::cerr << val << endl;
        mx = max(mx, val);

        if (!f.count(val)) {
            f[val] = ++nr;
        } else {
            continue;
        }

        vector<int> ps;
        int id = f[val];
        for (int i = 1; i <= n; ++i) {
            if (val % a[i] == 0 && !mark[i]) {
                ps.push_back(i);
                v[id].push_back(i);
            }
        }

        for (int i = 1; i <= nr; ++i) {
            viz[i] = false;
        }

        bool ch = cuplaj(id);

        int nc = dim + ch;
        if (nc > dim) {
            for (auto it : ps) {
                ++mul[it];
                s.insert(1LL * a[it] * mul[it]);
            }
        } else {
            for (auto it : ps) {
                mark[it] = 1;
            }
        }

        if (nc == n) {
            break;
        }
        dim = nc;
    }

    for (int i = 1; i <= nr; ++i) {
        v[i].clear();
        l[i] = 0;
        r[i] = 0;
    }
    cout << mx << "\n";
}

int main() {
    cin.tie(NULL);
    ios::sync_with_stdio(false);

    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}