t=int(raw_input())
ans=[]
for i in range(t):
    N=long(raw_input())
    if N==1:
        ans.append(1)
    elif N==2:
    	ans.append(8)
    else:
        val3=long(N*N*N)
        val2=long((N-2)*(N-2)*(N-2))
        val=val3-val2
        ans.append(val)
for x in ans:
    print(x)