#include<iostream>
using namespace std;
const int N=1e8+5,M=1e7+5;
int n,m,q,idx;
int s[M];
bool flag[N];
int main()
{
cin>>n>>m;
for(long long i=2;i<=n;i++){
if(flag[i]==0){
s[++idx]=i;
for(long long j=i*i;j<=n;j+=i)
flag[j]=1;
}
}
while(m--)
{
cin>>q;
cout<<s[q]<<endl;
}
return 0;
}