#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+1;
vector <ll> prime;
void func()
{
    vector <ll> arr(N);
    for(ll i=2;i<N;i++)
    arr[i]=1;
    for(ll i=2;i*i<N;i++)
    {
        if(arr[i])
        {
            for(ll j=i*i;j<N;j+=i)
            arr[j]=0;
        }
    }
    for(ll i=2;i<N;i++)
    {
        if(arr[i])
        prime.push_back(i);
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    func();
    while(t--)
    {
        ll d;
        cin>>d;
        ll idx1=lower_bound(prime.begin(),prime.end(),1+d)-prime.begin();
        ll val1=prime[idx1];
        ll idx2=lower_bound(prime.begin(),prime.end(),val1+d)-prime.begin();
        ll val2=prime[idx2];
        ll ans=val1*val2;
        cout<<ans<<"\n";
    }
    return 0;
}