#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

vector<int64_t> Primes(int64_t n) {
    vector<int64_t> primes;
    vector<bool> is_prime(n + 1, true);

    for (int64_t i = 2; i <= n; i += 1) {
        if (!is_prime[i]) {
            continue;
        }
        primes.push_back(i);

        for (auto j = i * i; j <= n; j += i) {
            is_prime[j] = false;
        }
    }
    return primes;
}

int64_t PrimeGreaterThan(int64_t n) {
    static vector<int64_t> primes = Primes(200000);

    int pos = -1;
    int pow = 1 << 25;

    while (pow > 0) {
        auto next = pos + pow;
        pow >>= 1;

        if (next < (int)primes.size() && primes[next] <= n) {
            pos = next;
        }
    }
    return primes[pos + 1];
}

int64_t Solve(int n) {
    auto f1 = PrimeGreaterThan(n);
    auto f2 = PrimeGreaterThan(f1 + n - 1);

    return f1 * f2;
}

int main() {
    int tests;
    cin >> tests;

    for (int i = 0; i < tests; i += 1) {
        int n;
        cin >> n;
        cout << Solve(n) << "\n";
    }
    return 0;
}
