#include <iostream>

long long calc(long long n)
{
    long long res = 1;
    res += n;                            // ahead (no turns)
    if(n >= 1) res += (n - 1)*2;         // left/right (1 turn)
    if(n >= 2) res += (n - 2);           // back (2 turns)
    if(n >= 2) res += (n - 1)*(n - 2);   // ahead and left/right (1 turn)
    if(n >= 3) res += (n - 2)*(n - 3);   // left/right and back (2 turns)
    return res;
}

int main()
{
    int runs;
    std::cin >> runs;
    while(runs--)
    {
        long long n;
        std::cin >> n;
        std::cout << calc(n) << '\n';
    }
}
