import sys def input(): return sys.stdin.buffer.readline()[:-1] for _ in range(int(input())): p = int(input()) if p == 2: print(2) else: print((p-1)**2)