#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

const int MAXN = 50005;

int T;
long long d;
bool composite[MAXN + 5];

int main() {
     
    ios_base::sync_with_stdio(0);
    cin.tie (0);
    cout.tie (0);

    cin >> T;
    set<long long> primes;
    for(int i = 2; i <= MAXN; i++){
        if(!composite[i]){
            primes.insert(i);
            for(int j = 2 * i; j <= MAXN; j += i)
                composite[j] = true;
        }
    }

    while(T--){
        cin >> d;
        long long a = *primes.lower_bound(d + 1LL);
        long long b = *primes.lower_bound(a + d);
        // cout << a << " " << b << "\n";
        cout << a * b << '\n';
    }

}