n = int(input()) for _ in range(n): p = int(input()) print(2 if p == 2 else (p - 1) ** 2)