#include using namespace std; using pii = pair; using ll = long long; using pll = pair; using i64 = __int128_t; int sieve[10000001]; vector p, v; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); for (int i = 2; i <= 10000000; i++) { if (!sieve[i]) { p.push_back(i); for (int j = 2; i*j <= 10000000; j++) { sieve[i*j] = 1; } } } for (int i = 2; i < p.size(); i++) { if (p[i]*p[i-1] > 100'000'000'000'000LL) break; v.push_back(p[i]*p[i-1]); } int t; cin >> t; while (t--) { ll x; cin >> x; int idx = upper_bound(v.begin(), v.end(), x) - v.begin() - 1; if (idx >= 0) cout << v[idx] << "\n"; else cout << "-1\n"; } }