#ifdef __LOCAL #define _GLIBCXX_DEBUG #include "debug2.h" #endif #ifndef __LOCAL #define show(...) #define SET_GROUP(x) #define SET_MAXCNT(x) #endif #include using namespace std; //#include //using namespace atcoder; //#include //using bigint = boost::multiprecision::cpp_int; #define SIZE(x) (int)(x.size()) #define ALL(x) x.begin(),x.end() using ll = long long; //int di[] = {1, 0, -1, 0, 1, -1, -1, 1}; //int dj[] = {0, 1, 0, -1, 1, 1, -1, -1}; templatebool chmin(T& x,T y){if(x>y){x=y;return true;}return false;} templatebool chmax(T& x,T y){if(xvectormatrix(int n1,T val){return vector(n1,val);} templatevector>matrix(int n1,int n2,T val){return vector>(n1,matrix(n2,val));} templatevector>>matrix(int n1,int n2,int n3,T val){return vector>>(n1,matrix(n2,n3,val));} templatevector>>>matrix(int n1,int n2,int n3,int n4,T val){return vector>>>(n1,matrix(n2,n3,n4,val));} templateT sum(vectorx){T r=0;for(auto e:x)r+=e;return r;} templateT max(vectorx){T r=x[0];for(auto e:x)chmax(r,e);return r;} templateT min(vectorx){T r=x[0];for(auto e:x)chmin(r,e);return r;} templatesettoSet(vectorx){set r;for(auto e:x)r.emplace(e);return r;} templatemaptoMap(vectorx){mapmp;for(auto e:x)mp[e]++;return mp;} templatevectortoVector(setx){vector r;for(auto e:x)r.push_back(e);return r;} templatepair operator+(pairx,pairy){return make_pair(x.first+y.first,x.second+y.second);} templatepair operator-(pairx,pairy){return make_pair(x.first-y.first,x.second-y.second);} templateistream&operator>>(istream&is,tuple&x){cin>>get<0>(x)>>get<1>(x);return is;} templateistream&operator>>(istream&is,tuple&x){cin>>get<0>(x)>>get<1>(x)>>get<2>(x);return is;} templateistream&operator>>(istream&is,pair&x){cin>>x.first>>x.second;return is;} templateistream&operator>>(istream&is,vector&x){for(auto&&e:x)is>>e;return is;} templateistream&operator>>(istream&is,vector>&x){for(auto&&e:x)for(auto&&f:e)is>>f;return is;} templateostream&operator<<(ostream&os,const vector&x){for(auto e:x)os<ostream&operator<<(ostream&os,const vector>&x){for(auto e:x){for(auto f:e)os< primes; vector isprime(maxN, true); for(ll i = 2; i < maxN; ++i){ if(!isprime[i]) continue; primes.push_back(i); for(ll j = 2 * i; j < maxN; j += i){ isprime[j] = false; } } vector prodPrime; for(int i = 0; i < SIZE(primes) - 1; ++i){ if(primes[i] + 2 == primes[i + 1]){ prodPrime.push_back(primes[i] * primes[i + 1]); } } int t; cin >> t; for(int i = 0; i < t; ++i){ ll p; cin >> p; if(p < 15){ cout << -1 << endl; }else{ ll a = lower_bound(ALL(prodPrime), p + 1) - prodPrime.begin() - 1; //chmin(a, SIZE(prodPrime) - 1); //show(a, SIZE(prodPrime)); cout << prodPrime[a] << endl; } } return 0; }