#include<bits/stdc++.h>
using namespace std;
bool nt(int n)
{
    if(n<=1)
        return false;
    for(int i=2;i*i<=n;i++)
        if(n%i==0)
        return false;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    freopen("CAU3.INP","r",stdin);
    freopen("CAU3.OUT","w",stdout);
    int t,n,dem=0;
    cin>>t;
    while(t--)
    {
        cin>>n;
        if(nt(n))
            cout<<n<<endl;
        else
        {
            for(int i=1;i<=100;i++)
            {
                if(nt(n+i))
                {
                    cout<<n+i<<endl;
                    break;
                }
            }
        }
    }
}
