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

#define rs ranges::

using bs = bitset<2000>;

using i64 = int64_t;

void solve() {
    int n;
    cin >> n;

    vector<i64> vv(n);
    for (auto &e: vv) cin >> e;

    map<i64, int> mp;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= n; ++j) {
            mp[vv[i] * j] = 0;
        }
    }

    int cnt = 0;
    vector<i64> inv;
    for (auto &[k, val] : mp) {
        val = cnt++;
        inv.push_back(k);
    }

    vector<vector<int>> g(n + cnt);
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= n; ++j) {
            g[mp[vv[i] * j] + n].push_back(i);
            g[i].push_back(mp[vv[i] * j] + n);
        }
    }

    vector<bs> adj(cnt);
    int matched_cnt = 0;
    vector<int> matched(n + cnt, -1);
    for (int i = n; i < n + cnt; ++i) {
        for (int j: g[i]) {
            adj[i - n].set(j);
        }
    }
    for (int i = n; i < n + cnt; ++i) {
        bs vis;
        auto dfs = [&](auto &&self, int u) -> bool {
            if (u < n) {
                vis.set(u);
                if (matched[u] == -1) return true;
                return self(self, matched[u]);
            }
            int v = -1;
            while (true) {
                int nxt;
                if (v == -1) nxt = (adj[u - n] & ~vis)._Find_first();
                else nxt = (adj[u - n] & ~vis)._Find_next(v);
                if (nxt == adj[u - n].size()) break;
                if (self(self, nxt)) {
                    if (matched[u] != -1) adj[u - n].set(matched[u]);
                    matched[u] = nxt;
                    matched[nxt] = u;
                    adj[u - n].reset(matched[u]);
                    return true;
                }
                v = nxt;
            }
            return false;
        };
        if (dfs(dfs, i)) {
            cerr << endl;
            ++matched_cnt;
        }
        if (matched_cnt == n) {
            cout << inv[i - n] << '\n';
            return;
        }
    }


}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}