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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n = input()
while n > 0:
    n -= 1
    curr = input()
    print (pow(curr,3) - (0 if curr-2 <= 0 else pow(curr-2,3)))