v=[0]*(10**7+10**6) for x in range(2,10**7+10**6): if v[x]==1: continue for y in range(2,10**7): if x*y>=10**7+10**6: break v[x*y]=1 p=[] for x in range(2,10**7+10**6-1): if v[x]==0 and v[x+2]==0: p.append(x) Q=int(input()) from math import isqrt from bisect import bisect_right for _ in range(Q): N=int(input()) K=isqrt(N) pos=bisect_right(p,K) result=-1 for e in range(pos-5,pos+5): if e<0: continue x=p[e] if x*(x+2)<=N: result=max(result,x*(x+2)) print(result)