'''
# 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 i in range(T):
    N = int(raw_input())
    if N==1:
        result=1
    else :
        result = (6*(N**2))-(12*N)+8
    print result