import sys
sys.setrecursionlimit(10**7)

n = int(input())
t = [int(input()) for i in range(n)]
#print(t)

ans = [0]*(10**7+1)

from functools import lru_cache
@lru_cache(maxsize=10**7)
def dfs(x):
    if x == 3:
        return 4
    ans[x] += dfs(x-1)+(x-1)*(x-2)*2
    return ans[x]

for i in range(n):
    #print(t[i],i)
    print(dfs(t[i]))
    #print(i)