cnt = [0] * (10 ** 6 + 1)
cnt[3] = 4
total = 4
total2 = 4
for i in range(4, len(cnt)):
    total2 += total
    cnt[i] = total2 + (i-2) * 4
    total2 += (i-2) * 4
    total += (i-2) * 4


T = int(input())
for _ in range(T):
    print(cnt[int(input())])