/*
  [BAPC'07] HERBERT
  by: Jan Kuipers
*/

using namespace std;

#include <iostream>

int main () {

  int runs;
  cin>>runs;
  while (runs--) {
    int N;
    cin>>N;
    if (N==0) cout<<1<<endl;
    if (N==1) cout<<2<<endl;
    if (N>=2) cout<<2LL*N*N-4LL*N+5<<endl;		
  }

  return 0;
}
