text: """
  # Sample code to perform I/O:
  
  name = input()                  # Reading input from STDIN
  print('Hi, %s.' % name)         # Writing output to STDOUT
  
  # Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
  """
  
  # Write your code here
  t = int(input())
  for _ in range(t):
      n = int(input())
      if n < 3:
          ans = n ** 3
      else:
          ans = n ** 3 - (n - 2) ** 3
      print(ans)
  