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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T= int(raw_input(""))
while (T>0):
	T-=1
	N=int(raw_input())
	if N==1:
		print 1
	else:
		print 2*(3*N*(N-2)+4)