N=int(input()) X=[-1]*N for i in range(N): p=int(input()) if p!=2: X[i]=(p-1)**2 else: X[i]=2 print(*X,sep="\n")