#include <stdlib.h> 
#include <string.h> 
#include <stdio.h> 
#include <limits.h> 
#include <ctype.h> 
#include <set>
#include <queue>
using namespace std;

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) < (b) ? (b) : (a))

int run ()
{
	long long x, ans=0;
	scanf("%lld\n",&x);
	if(x==0) ans = 1;
	else if(x==1) ans = 2;
	else
	{
		ans += 2*x*x;
		ans += -4*x;
		ans += 5;
	}
	printf("%lld\n",ans);
	return 0;	
}

int main ()
{
    int N,i;
    scanf("%d\n", &N);
    
    for(i=0;i<N;i++) run();
    
    exit (0);
}
