#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define mod 1000000007


ll pow(ll a,ll b)
{
    ll res = 1;
    while(b>0)
    {
        if(b&1) res = res*a;
        a = a*a;
        b >>=1;
    }
    return res;
}
ll pow_mod(ll a,ll b)
{
    ll  res = 1;
    while(b>0)
    {
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b >>=1;
    }
    return res;
}
ll inv(ll a)
{
    return pow_mod(a,mod-2);
}

int primes[100001]={0};
void seive()
{
    primes[0]=primes[1] = 1;
    for(int i=2;i*i<=100000;i++)
    {
        if(primes[i]==0)
        {
            for(int j=i+i;j<=100000;j+=i)
            {
                primes[j] = 1;
            }
        }
    }
}
void solve()
{
    int d;
    cin>>d;
    int a=0,b=0;
    for(int i=1+d;i<100000;i++)
    {
        if(primes[i]==0)
        {
            a = i;
            break;
        }
    }
    for(int i=a+d;i<100000;i++)
    {
        if(primes[i]==0)
        {
            b = i;
            break;
        }
    }
    cout<<a*b<<endl;
}
int main()
{
    seive();
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}