#include <bits/stdc++.h>
using namespace std;
#define fwd(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) fwd(i, 0, n)
#define all(X) X.begin(), X.end()
#define sz(X) int(size(X))
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
using pii = pair<int, int>; using vi = vector<int>;
using ll = long long; using ld = long double;
#ifdef LOC
auto SS = signal(6, [](int) {* (int *) 0 = 0;});
#define DTP(x, y) auto operator << (auto& o, auto a) -> decltype(y, o) {o << "("; x; return o << ")";}
DTP(o << a.st << ", " << a.nd, a.nd);
DTP(for(auto i : a) o << i << ", ", all(a));
void dump(auto... x) {((cerr << x << ", "), ...) << "\n";}
#define deb(x...) cerr << setw(4) << __LINE__ << ":[" #x "]: ", dump(x)
#else
#define deb(...) 0
#endif

int matching(vector<vi> &G, vi &match) {
    vector<bool> seen; int n = 0, k = 1;
    match.assign(sz(G), -1);
    auto dfs = [&](auto f, int i) -> int {
        if (seen[i]) return 0; seen[i] = 1;
        for (auto e : G[i]) {
            if (match[e] < 0 || f(f, match[e])) {
                match[i] = e; match[e] = i; return 1;
            }
        }
        return 0;
    };
    while (k) {
        seen.assign(sz(G), 0); k = 0;
        rep(i, sz(G)) if (match[i] < 0) k += dfs(dfs, i);
        n += k;
    }
    return n;
}

void sol() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> vec;

    for (ll x : a) {
        fwd(i, 1, n+1) {    
            vec.pb(x*i);
        }
    }

    sort(all(vec));
    vec.erase(unique(all(vec)), vec.end());

    vector<vi> gall(n);

    rep(id, n) {
        fwd(i, 1, n+1) {
            ll x = a[id] * i;
            auto it = lower_bound(all(vec), x);
            int here = int(it - vec.begin());
            gall[id].pb(here);
        }
    }

    deb(vec);
    rep(i, n) deb(i, a[i], gall[i]);

    int l = 0, r = sz(vec);
    while (r - l > 1) {
        int mid = (l + r) / 2;

        vector<vi> g(n + mid);

        rep(i, n) {
            for (int id : gall[i]) if (id < mid) {
                g[i].pb(id + n);
                g[id + n].pb(i);
            }
        }

        vi match;
        int ile = matching(g, match);

        if (ile == n) r = mid;
        else l = mid;
    }

    cout << vec[r-1] << '\n';
}

int32_t main(){
    cin.tie(0)->sync_with_stdio(0);
    cout << fixed << setprecision(10);

    int z;
    cin >> z;
    while (z--) sol();

    return 0;
}