n = int(input()) p = [int(input()) for i in range(n)] for val in p: if val == 2: print(2) else: print(val ** 2 - 2 * val + 1)