
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const unsigned int mod = 1000000007;




int main(){

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

  bool prime[1000001]; 
memset(prime, true, sizeof(prime)); 
  
for(int p=2; p*p<=1000000; p++) { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        {   
            for (int i=p*p; i<=1000000; i += p) 
                prime[i] = false; 
        } 
}


  ll t;
  cin>>t;
  while(t--){
    int a;
    cin>>a;
    int ans = 1;
    for(int i=a+1;i<1000001;i++){
      if (prime[i]){
        ans*=i;break;
      }
    }
    for(int i=ans+a;i<1000001;i++){
      if (prime[i]){
        ans*=i;break;
      }
    }
    cout<<ans<<endl;
  }


  return 0;
}
