#include<bits/stdc++.h>

using namespace std;

const int MAXN = 50000;

bool vis[MAXN + 5];
int t, d, cnt, p[5155];

void Init()
{
    for (int i = 2; i <= MAXN; i++)
    {
        if (!vis[i]) p[cnt++] = i;
        for (int j = 0; j < cnt && i * p[j] <= MAXN; j++)
        {
            vis[i * p[j]] = true;
            if (i % p[j] == 0) break;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    Init();
    cin >> t;
    while (t--)
    {
        cin >> d;
        int pp, q, pos;
        for (int j = 0; j < cnt; j++)
        {
            if (p[j] - 1 >= d)
            {
                pp = p[j];
                pos = j;
                break;
            }
        }
        for (int j = pos + 1; j < cnt; j++)
        {
            if (p[j] - pp >= d)
            {
                q = p[j];
                break;
            }
        }
        cout << 1ll * pp * q << '\n';
    }
    return 0;
}