#include <iostream>
#include <cstring>
using namespace std;
#define endl '\n'
#define re register
#define inl inline
const int MAXN = 1e8+5;
inl void seive(re int n,re bool a[]){
memset(a,0,sizeof(bool) * (n+1));
a[0] = a[1] = 1;
for (int i=2;i*i<=n;i++)
if (a[i] == 0)
for (int j = i << 1;j <= n;j += i)
a[j] = 1;
}
inl int read(){
re int d = 0,s = 1;
re char ch = getchar();
while (ch < '0' || ch > '9'){
if (ch == '-') s = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
d = d * 10 + (ch - '0'),ch = getchar();
return d * s;
}
inl void write(re int x){
if (x < 0) putchar('-'),x = -x;
if (x > 9) write(x/10);
putchar(x % 10 + '0');
}
int p[MAXN];
bool a[MAXN];
int n,q,k,pail=1;
signed main(){
n = read();
q = read();
seive(n,a);
for (re int i=1;i<=MAXN,pail<=n;i++)
if (a[i] == 0)
p[pail++] = i;
for (int i=1;i<=q;i++) k = read(),write(p[k]),putchar('\n');
return 0;
}