#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define len(x) (int)(x.size()) #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef long double ld; bool umin(int& a, int b) { if(b < a) { a = b; return true; } return false; } bool umax(int& a, int b) { if(b > a) { a = b; return true; } return false; } //#ifdef KoRoVa //#define DEBUG for (bool __DEBUG=1;__DEBUG;__DEBUG=0) //#define LOG(...) prnt(#__VA_ARGS__" ::",_VA_ARGS)<<endl //#else //#define DEBUG while(false) //#define LOG(...) if(false) //#endif template <class ...Ts> auto &prnt(Ts ...ts) { return ((cerr << ts << " "), ...); } const int max_n = 2042, inf = 1000111222; const ll linf = 1000111222000111222; vector<int> g[max_n]; ll kek[max_n * max_n]; int used[max_n], timer = 0, mt[max_n * max_n], mx; inline bool dfs (int v) { if (used[v] == timer) { return false; } used[v] = timer; for (int to : g[v]) { if (mt[to] == -1 || dfs(mt[to])) { mt[to] = v; umax(mx, to); return true; } } return false; } void test_case() { mx = 0; int n; cin >> n; for (int i = 0; i < n; i++) { g[i].clear(); } vector<int> a(n); for(auto& x : a) cin >> x; int ind = 0; for(int i = 0; i < n; i++) { for(int j = 1; j <= n; j++) kek[ind++] = j * 1ll * a[i]; } sort(kek, kek + ind); int sz = unique(kek, kek + ind) - kek; for (int i = 0; i < sz; i++) { mt[i] = -1; } for(int i = 0; i < n; i++) { for(int j = 1; j <= n; j++) g[i].pb(lower_bound(kek, kek + sz, j * 1ll * a[i]) - kek); } for (int i = 0; i < n; i++) { // cerr << i << '\n'; ++timer; dfs(i); } cout << kek[mx] << '\n'; } signed main() { // freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(false); cin.tie(nullptr); int testcases = 1; cin >> testcases; while(testcases--) test_case(); exit(0); }