#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define mst( a ) memset( (a) ,0,sizeof( (a) ) )
//#define local
const int manx=100001;
int not_prime[manx][17],num[manx];
void divider()
{
mst(not_prime);
for(int i=2;i<manx;++i){
if(!not_prime[i][0]){
for(int j=i;j<manx;j+=i)
not_prime[j][++not_prime[j][0]]=i;
}
}
return;
}
void transf(int n)
{
int bits=(1<<not_prime[n][0])-1;
for(int i=1;i<=bits;++i){
int t=1;
for(int j=1;j<=not_prime[n][0];++j){
if(i&(1<<(j-1)))
t*=not_prime[n][j];
}
++num[t];
}
return;
}
int calc(int n)
{
int ans=0;
int bits=(1<<not_prime[n][0])-1;
for(int i=1;i<=bits;++i){
int t=1,cnt=0;
for(int j=1;j<=not_prime[n][0];++j){
if(i&(1<<(j-1))){
t*=not_prime[n][j];
++cnt;
}
}
if(cnt&1)ans+=num[t];
else ans-=num[t];
}
return ans;
}
void Solve()
{
int n,t;
scanf("%d%d",&n,&t);
mst(num);
for(int i=0,j;i<n;++i){
scanf("%d",&j);
transf(j);
}
for(int i=0,j;i<t;++i){
scanf("%d",&j);
printf("%d\n",n-calc(j));
}
return;
}
int main()
{
#ifdef local
freopen("input.txt","r",stdin);
#endif
divider();
Solve();
return 0;
}