'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T=int(input())
for i in range(0,T):
	N=int(input())
	if(N>2):
		S=N-2
		print(N*N*N-S*S*S)
	else:
		print(N*N*N)