#pragma GCC optimize("O3,unroll-loops")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define el cout<<"\n"
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define fz(i,a,n,z) for(int i=a;i<n;i+=z)
#define rep(i,a,n,z) for(int i=a;i>n;i-=z)
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define file(name) freopen(name".inp","r",stdin);freopen(name".out","w",stdout);
bool checkprime(ll n)
{
if(n == 2 || n == 3) return true;
if(n < 2 || n%2 == 0 || n%3 == 0) return false;
for(int i = 5; 1ll*i*i <= n; i+=6){
if(n%i == 0 || n%(i+2) == 0) return false;
}
return true;
}
const int maxn = 2e6 + 1;
vector<int> prime;
int D[maxn];
void Sieve(){
for(int i=2;i<=sqrt(maxn);++i){
if(D[i] == 0){
for(int j=i;j<=maxn/i;++j){
D[i*j] = 1;
}
}
}
for(int i=2;i<=maxn;++i) if(D[i] == 0) prime.push_back(i);
}
int main() {
faster
file("MPRI")
int q;
cin>>q;
ll n;
if(q<=100){
while(q--){
cin>>n;
while(!checkprime(n)) ++n;
cout<<n<<"\n";
}
}
else
{
Sieve();
while(q--){
cin>>n;
int vt = lower_bound(all(prime), n) - prime.begin();
cout<<prime[vt]<<"\n";
}
}
}