#include <bits/stdc++.h> using namespace std; #define vt vector #define ll long long #define rall(x) (x).rbegin(), (x).rend() const char nl = '\n'; void solve() { int N; cin >> N; vt<ll> v(N); for(auto& x : v) cin >> x; set<ll> done; sort(rall(v)); for(auto x : v) { ll me = x; while(done.count(me)) me += x; done.insert(me); } cout << *prev(done.end()) << "\n"; } int main() { ios::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while(T--) { solve(); } }