#include<iostream>
#include<string.h>
#include<algorithm> 
#include<math.h>
using namespace std;
//int gcd(int a,int b){
//	return b==0?a:gcd(b,a%b);
//}
bool prime(int x){
	if(x==2)return true;
	else if(x%2==0)return false;
	for(int i=3; i*i<=x; i+=2){
		if(x%i==0)return false;
	}
	return true;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		int d;
		cin>>d;
		int x=1+d;
//		cout<<prime(5)<<endl;
		while(!prime(x))x++;
		int y=x+d;
		while(!prime(y))y++;
//		cout<<x<<' '<<y<<endl;
		cout<<x*y<<endl;
	}
	return 0;
}
	
		   		  		  	   	     	 		 	