// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define cps CLOCKS_PER_SEC
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
#define MOD 1000000007
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
int power(int x,int y){ int res = 1; while(y>0){ if(y&1) res = (res*x)%MOD;
y >>= 1; x = (x*x)%MOD; } return res; }
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;
const int MAXN = 1e5 + 10;
int M[MAXN],phi[MAXN];
int is_composite[MAXN];
vector<int> prime;
void linear_seive_with_mobius_and_phi(){
M[1] = 1,phi[1] = 1;
for(int i=2;i<MAXN;i++){
if(!is_composite[i]){
prime.push_back(i);
M[i] = -1,phi[i] = i-1;
}
for(int j=0;j<prime.size() && i*prime[j] < MAXN;j++){
is_composite[i*prime[j]] = true;
if(i%prime[j] == 0){
M[i*prime[j]] = 0;
phi[i*prime[j]] = phi[i]*prime[j];
break;
}else {
M[i*prime[j]] = M[i]*M[prime[j]];
phi[i*prime[j]] = phi[i]*phi[prime[j]];
}
}
}
}
int a[MAXN];
int freq[MAXN];
int sum[MAXN];
int ans[MAXN];
void solve(){
int n,q; cin>>n>>q;
FOR(i,1,n){
cin>>a[i]; freq[a[i]]++;
}
FOR(i,1,MAXN-1){
for(int j=i;j<MAXN;j+=i){
sum[i] += freq[j];
}
}
for(int g=1;g<MAXN;g++){
for(int l=g;l<MAXN;l+=g){
ans[g] += sum[l]*sum[l]*M[l/g];
}
ans[g] += freq[g];
ans[g] /= 2;
}
while(q--){
int k; cin>>k;
cout<<ans[k]<<endl;
}
}
signed main(){
FastRead;
linear_seive_with_mobius_and_phi();
int t = 1;
// cin>>t;
FOR(i,1,t){
// cout<<"Case #"<<i<<": ";
solve();
}
}
Ly8gI3ByYWdtYSBHQ0MgdGFyZ2V0ICgiYXZ4MiIpCi8vICNwcmFnbWEgR0NDIG9wdGltaXphdGlvbiAoIk8zIikKLy8gI3ByYWdtYSBHQ0Mgb3B0aW1pemF0aW9uICgidW5yb2xsLWxvb3BzIikKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBGYXN0UmVhZCBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsgY2luLnRpZSgwKTsgY291dC50aWUoMCk7CiNkZWZpbmUgaW50IGxvbmcgbG9uZyBpbnQKI2RlZmluZSBsbCBpbnQKI2RlZmluZSBjcHMgQ0xPQ0tTX1BFUl9TRUMKI2RlZmluZSBiaXRzX2NvdW50IF9fYnVpbHRpbl9wb3Bjb3VudGxsCiNkZWZpbmUgZW5kbCAnXG4nCiNkZWZpbmUgZG91YmxlIGxvbmcgZG91YmxlCiNkZWZpbmUgbGQgZG91YmxlCiNkZWZpbmUgRk9SKGksYSxuKSBmb3IgKGxsIGk9KGEpO2k8PShuKTsrK2kpCiNkZWZpbmUgUkZPUihpLGEsbikgZm9yIChsbCBpPShuKTtpPj0oYSk7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wogICAgICAgICAgICAgICAgcGhpW2kqcHJpbWVbal1dID0gcGhpW2ldKnBoaVtwcmltZVtqXV07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0KCmludCBhW01BWE5dOwppbnQgZnJlcVtNQVhOXTsKaW50IHN1bVtNQVhOXTsKaW50IGFuc1tNQVhOXTsKCnZvaWQgc29sdmUoKXsKICAgIGludCBuLHE7IGNpbj4+bj4+cTsKICAgIEZPUihpLDEsbil7CiAgICAgICAgY2luPj5hW2ldOyBmcmVxW2FbaV1dKys7CiAgICB9ICAgIAoKICAgIEZPUihpLDEsTUFYTi0xKXsKICAgICAgICBmb3IoaW50IGo9aTtqPE1BWE47ais9aSl7CiAgICAgICAgICAgIHN1bVtpXSArPSBmcmVxW2pdOwogICAgICAgIH0KICAgIH0KCiAgICBmb3IoaW50IGc9MTtnPE1BWE47ZysrKXsKICAgICAgICBmb3IoaW50IGw9ZztsPE1BWE47bCs9Zyl7CiAgICAgICAgICAgIGFuc1tnXSArPSBzdW1bbF0qc3VtW2xdKk1bbC9nXTsKICAgICAgICB9CiAgICAgICAgYW5zW2ddICs9IGZyZXFbZ107CiAgICAgICAgYW5zW2ddIC89IDI7CiAgICB9CgogICAgd2hpbGUocS0tKXsKICAgICAgICBpbnQgazsgY2luPj5rOwogICAgICAgIGNvdXQ8PGFuc1trXTw8ZW5kbDsKICAgIH0KfQogCnNpZ25lZCBtYWluKCl7CgogICAgRmFzdFJlYWQ7IAoKICAgIGxpbmVhcl9zZWl2ZV93aXRoX21vYml1c19hbmRfcGhpKCk7CiAgICBpbnQgdCA9IDE7IAogICAgLy8gY2luPj50OwogICAgRk9SKGksMSx0KXsKICAgICAgICAvLyBjb3V0PDwiQ2FzZSAjIjw8aTw8IjogIjsKICAgICAgICBzb2x2ZSgpOwogICAgfQp9Cgo=