I=input for i in range(int(I())):p=int(I());print([(p-1)**2,2][p==2])