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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
tc = int(raw_input())
if tc>=1 and tc<=100:
	for i in range(0,tc,1):
		side = int(raw_input())
		if side>1 and side<=(pow(10,9)):
			sside = side - 2
			tvol = side * side * side
			dvol = sside * sside * sside
			svol = tvol - dvol
			print svol
		elif side==1:
			print "1"
		else:
			print "Constraint Violation"
else:
	print "Constraint Violation"