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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

a=input()

for i in range(0,a):
	b=input()
	if b==1 :
		print 1
	else:
		print 2*(3*b*(b-2)+4)