#include <iostream>
using namespace std;
const int N=1000000+1;
long long freq[N];
void solve()
{
freq[0]=0;
freq[1]=1;
freq[2]=5;
freq[3]=15;
long long z=10;
long long weee=9;
for(int i=4;i<N;i++){
z+=weee;
freq[i]=freq[i-1]+z;
weee+=3;
}
}
int main()
{
solve();
int t;cin>>t;
for(int i=0;i<t;i++){
int x;cin>>x;
cout<<freq[x]<<endl;
}
return 0;
}