#include #include using namespace std; using namespace atcoder; using lli=long long int; using ld=long double; using vi=vector; using vvi=vector; using vvvi=vector; using vvvvi=vector; using vl=vector; using vvl=vector; #define rep(i,s,e) for(int i=s;i=e;i--) #define in(v,seq) for(auto v:seq) #define veci(v,s) vi v(s); rep(i,0,s) cin >> v.at(i); #define vecl(v,s) vl v(s); rep(i,0,s) cin >> v.at(i); #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() using pii=pair; using pll=pair; #define mp(f,s) make_pair(f,s) #define fi first #define se second using vpii=vector; using vpll=vector; #define vecpii(v,s) vpii v(s); rep(i,0,s) cin >> v.at(i).fi >> v.at(i).se; #define vecpll(v,s) vpll v(s); rep(i,0,s) cin >> v.at(i).fi >> v.at(i).se; #define pub(x) push_back(x) #define puf(x) push_front(x) #define pob(x) pop_back(x) #define pof(x) pop_front(x) #define eb(x) emplace_back(x) #define print(s) cout << s << endl; const int I_INF=1<<30; const lli LL_INF=1ll<<61; const string alp="abcdefghijklmnopqrstuvwxyz"; const int let=alp.size(); // 26 const int nmax=10000000; void sieve(vector &isp,lli len){ isp.assign(len+1,true); isp.at(0)=isp.at(1)=false; for(lli i=2;i<=(len+1)/2;i++){ lli pointer=i*i; while(pointer<=len){ isp.at(pointer)=false; pointer+=i; } } return; } int main(){ int q; cin >> q; vector isp; sieve(isp,nmax); vl anss; anss.pub(-1); repl(i,1,nmax-2){ if(isp[i] && isp[i+2]) anss.pub(i*(i+2)); } rep(i,0,q){ lli n; cin >> n; auto ans=upper_bound(all(anss),n)-1; print(*ans); } }