'''
# 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())
for _ in range(t):
	n = int(raw_input())
	if n == 1:
		print n
	else:
		print n*n*n - ((n-2)*(n-2)*(n-2))