#include <string>
#include <bits/functexcept.h>
#include <iosfwd>
#include <bits/cxxabi_forced.h>
#include <bits/functional_hash.h>
#pragma push_macro("__SIZEOF_LONG__")
#pragma push_macro("__cplusplus")
#define __SIZEOF_LONG__ __SIZEOF_LONG_LONG__
#define unsigned unsigned long
#define __cplusplus 201102L
#define __builtin_popcountl __builtin_popcountll
#define __builtin_ctzl __builtin_ctzll
#include <bitset>
#pragma pop_macro("__cplusplus")
#pragma pop_macro("__SIZEOF_LONG__")
#undef unsigned
#undef __builtin_popcountl
#undef __builtin_ctzl

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

#define rs ranges::

#pragma GCC target("avx2,popcnt,lzcnt")
#pragma GCC optimize("O3,unroll-loops")


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)) {
            ++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();
}