#include<bits/stdc++.h>
using namespace std;
bool numlist[100000050];
int prime[20000001],cnt;
int n,q;
void work(int n)
{
for(int i=2;i<=n;i++)
{
if(numlist[i]==false)
{
prime[++cnt]=i;
for(int j=i;i*j<n;j++)
{
numlist[i*j]=true;
}
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
work(n);
for(int i=1;i<=q;i++)
{
int k;
cin>>k;
cout<<prime[k]<<endl;
}
return 0;
}