#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt,tune=native")
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];

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;

void solve(){
    idx.clear();
    cin >> n;
    vector<ll> a(n);
    vector<ll> e;
    for(long long i = 0 ; i < n; i ++ ){
        cin >> a[i];
        T[i].clear();
        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;
    }
    for(int i = 0 ; i < n; i ++ ){
        for(int j = 1; j <= n; j ++ ){
            T[i].push_back(idx[a[i] * 1ll * j]);
        }
    }
    m = e.size();
    for(int i = 0 ; i < m ; i ++ ){
        mt[i] = -1;
    }
    for(int i = 0 ; i < m ; i ++ ){
        ind[i] = -1;
    }
    for(int run = 1; run;){
        run = 0;
        for(int i = 0 ; i < n; i ++ ) used[i] = 0;
        for(int i = 0 ; i < n; i ++ ){
            if(ind[i] == -1 && kuhn(i))
                run = 1;
        }
    }
    ll ans = 0;
    for(ll i = 0 ; i < n ; i ++ ){
        ans = max(ans, e[ind[i]]);
    }
    
    cout <<  ans << "\n";
}

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