#include<bits/stdc++.h>
using namespace std;
#define ll long long
#include<unordered_set>
#include<set>
#include <cmath>
#include<string>
#define pb push_back
#define vi vector<ll>
#define vii vector<vector<int>>
#define sd(a) scanf("%d",&a)
#define pr(a) printf("%d\n",a)
#define mod 998244353
#define f(i,a,b) for(i=a;i<b;i++)
int p[30001];
int t,d,a,b;
void solve(){

    for(int i=2;i<=30000;i++) if(!p[i])
        for(int j=2*i;j<=30000;j+=i) p[j]=1;
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
     solve();
     sd(t);
     while(t--){
        sd(d);
        for(a=1+d;p[a];++a);
        for(b=a+d;p[b];++b);
        pr(a*b);    
     }
    return 0;
}   