#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long long, long long> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const long long N = 2005;
const long long M = N * N;
vector<long long> T[N];
vector<int> R[M];

unordered_map<ll, long long> idx;

long long mt[M], ind[M];
bool used[M];

bool kuhn(long long u)
{
    if(used[u])
        return 0;
    used[u]=1;
    for(auto v: T[u])
    {
        if(mt[v]==-1||kuhn(mt[v]))
        {
            mt[v]=u;
            ind[u]=v;
            return 1;
        }
    }
    return 0;
}

long long n, m;
vector<ll> a;

void solve(){
    idx.clear();
    a.clear();
    cin >> n;
    a.resize(n);
    vector<ll> e;
    for(long long i = 0 ; i < n; i ++ ){
        cin >> a[i];
        for(long long j = 1; j <= n; j ++ ){
            e.push_back(a[i] * 1ll * j);
        }
    }
    sort(e.begin(), e.end());
    e.resize(unique(e.begin(), e.end()) - e.begin());
    for(long long i = 0 ; i < e.size(); i ++ ){
        idx[e[i]] = i;
        R[i].clear();
    }
    for(int i = 0 ; i < n ; i ++ ){
        for(ll x = 1; x <= n; x ++ ){
            ll w = a[i] * 1ll * x;
            ll moo = idx[w];
            R[moo].push_back(i);
        }
    }
    m = e.size();
    for(long long i = 0 ; i < m ; i ++ ){
        mt[i] = -1;
    }
    for(long long i = 0 ; i < n; i ++ ){
        ind[i] = -1;
        T[i].clear();
    }
    int fix = 0;
    for(int i = 0 ; i < m ; i ++ ){
        for(auto x : R[i]){
            T[x].push_back(i);
        }
        for(int x = 0; x < n; x ++ ){
            if(ind[x] == -1){
                for(int j = 0 ; j < n ; j ++ ) used[j]=false;
                fix = i;
                kuhn(x);
            }
        }
    }
    cout << e[fix] << "\n";
}

int main(){
    fastIO;
    long long tc;
    cin >> tc;
    for(long long iq = 1; iq <= tc; iq ++ ){
        solve();
    }
    return 0;
}