#include<bits/stdc++.h>
using namespace std;
const int N=1e8+10;
bool x[N];
long long n,q,k,p[N],cnt=0;
int main(){
std::ios::sync_with_stdio(0);
cout.tie(0);
freopen("33832.txt","w",stdout);
scanf("%ld%ld",&n,&q);
for(int i=1;i<q;i++){
scanf("%ld",&k);
for(int j=2;j<=n;j++){
if(!x[j]) p[++cnt]=j;
for(int r=1;p[r]*j<=n;r++){
x[p[r]*j]=1;
if(j%p[r]==0) break;
}
if(k==cnt){
cout << p[k] <<endl;
break;
}
}
cnt=0;
}
}