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

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

testcases=int(raw_input())

testdata=[]
for i in range(0,testcases):
    testdata.append(int(raw_input()))

for i in range(0,len(testdata)):
    if(testdata[i]<=1):
        print 1
    else:
      print (int(testdata[i]**3)-int((testdata[i]-2)**3))