#include<bits/stdc++.h>
#define endl "\n" 
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;
vector<ll>primes;
void do_once(){
    unordered_map<ll,int>ma;
    ma[2]=0;
    ma[3]=0;
    for(ll i=2;i*i<=1e6;i++){
        if(ma[i]==0){
            // i is prime
            ll index=2;
            while(i*index<=1e6){
                ma[i*index]=1;
                index++;
            }
        }
    }
    for(ll i=2;i<=1e6;i++)
    if(ma[i]==0)
    primes.push_back(i);
}
int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    do_once();
    int T;
    cin>>T;
    while(T--){
        ll d;
        cin>>d;
        ll firstPrime=*lower_bound(primes.begin(),primes.end(),d+1);
        ll secondPrime=*lower_bound(primes.begin(),primes.end(),firstPrime+d);
        cout<<firstPrime*secondPrime<<endl;
    }
}
