#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define sz(s) (i nt)(s.size())
#define all(v) v.begin(),v.end()
#define clr(d,v) memset(d,v,sizeof(d))
#define ll long long
#define ld long double
#define ull unsigned long long
int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };
ll gcd(ll x, ll y) { return(!y) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return((x / gcd(x, y)) * y); }
void file()
{
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
struct point
{
int x, y, dir, cnt;
point(int i, int j, int d, int c)
{
x = i;
y = j;
dir = d;
cnt = c;
}
};
int n, m;
bool vis[55][55][4];
int grid[55][55];
bool valid(int x, int y)
{
if (x <= 0 || y <= 0 || x >= n || y >= m)return false;
if (grid[x - 1][y - 1])return false;
if (grid[x - 1][y])return false;
if (grid[x][y - 1])return false;
if (grid[x][y])return false;
return true;
}
int bfs(pair<int, int>strt, pair<int, int>end, int d)
{
queue<point>q;
q.push(point( strt.first,strt.second,d,0 ));
vis[strt.first][strt.second][d] = true;
while (!q.empty())
{
point cur = q.front();
q.pop();
if (cur.x == end.first && cur.y == end.second)
return cur.cnt;
if (!vis[cur.x][cur.y][(cur.dir + 1) % 4])
{
vis[cur.x][cur.y][(cur.dir + 1) % 4] = true;
q.push(point( cur.x,cur.y,(cur.dir + 1) % 4,cur.cnt + 1 ));
}
if (!vis[cur.x][cur.y][(cur.dir + 3) % 4])
{
vis[cur.x][cur.y][(cur.dir + 3) % 4] = true;
q.push(point(cur.x, cur.y, (cur.dir + 3) % 4, cur.cnt + 1));
}
for (int i = 1; i <= 3; i++)
{
if (valid(cur.x + dx[cur.dir] * i, cur.y + dy[cur.dir] * i))
{
int a = cur.x + dx[cur.dir] * i;
int b = cur.y + dy[cur.dir] * i;
if (!vis[a][b][cur.dir])
{
q.push(point{ a,b,cur.dir,cur.cnt + 1 });
vis[a][b][cur.dir] = true;
}
}
else
break;
}
}
return -1;
}
int main()
{
file();
int t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
ll ans = (n * (n + 1)) / 2;
ans += n * ((n * (n - 1)) / 2);
cout << ans << "\n";
}
}
Copy