#include #include //小数点出力用 //cout << fixed << setprecision(10) << ans; #include #include #include #include #include #include #include using ll = long long; using namespace std; #define modPHash (ll)((1LL<<61)-1) #define modP (ll)998244353 bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); } int clk4(int num) { return (num - 2) * (num % 2); } void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T;cin >> T; bool notPrime[11000000] = { 0 }; notPrime[0] = 1; notPrime[1] = 1; vectorans; ans.push_back(-1); for (int i = 2;i < 11000000;i++) { if (notPrime[i] == 0) { for (int j = 2 * i;j < 11000000;j+=i) { notPrime[j] = 1; } if (notPrime[i - 2] == 0) { ans.push_back((ll)(i - 2) * (ll)i); } } } while (T--) { ll N; cin >> N; auto itr = upper_bound(ans.begin(), ans.end(), N); itr--; cout << (*itr) << "\n"; } return 0; }