// C++ program to display first N Prime numbers
#include <bits/stdc++.h>
using namespace std;

void solve(int N, set<int> &s)
{
	int i, j, flag;
for (i = 1; i <= N; i++) {

		if (i == 1 || i == 0)
			continue;

		flag = 1;

		for (j = 2; j <= i / 2; ++j) {
			if (i % j == 0) {
				flag = 0;
				break;
			}
		}

		if (flag == 1)
			s.insert(i);	}
}
int main()
{

	int N = 40000;
	set<int> s;
     solve(N,s);
     int t; cin>>t;
     while(t--)
     {

         int d,a1,a2; cin>>d;
         int x=d+1;
         while(s.find(x)==s.end())
            x++;
            a1=x;

            x+=d;
        while(s.find(x)==s.end())
            x++;
            a2=x;

         cout<<a1*a2<<"\n";
     }

}
