#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
long long mod = 1e9 + 7;
void time() {}
const long long N = 3100300;
const long long maxn = 1e5 + 5;
const long long despacito = 1e9 + 7;
long long n, m;
long long a[N], p[N], cnt[N], z[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cin >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> p[i];
  }
  for (long long i = 1; i <= n; i++) {
    cnt[a[i]]++;
  }
  for (long long a = 1; a <= N; a++) {
    if (!cnt[a]) continue;
    for (long long b = a; b < N; b += a) {
      if (b / a != a) {
        z[b] += (long long)(cnt[a] * cnt[b / a]);
      } else
        z[b] += (long long)(cnt[a] * (cnt[a] - 1));
    }
  }
  for (long long i = 1; i <= N; ++i) {
    z[i] += z[i - 1];
  }
  for (long long i = 1; i <= m; ++i) {
    long long ans = (long long)(n) * (n - 1) - z[p[i] - 1];
    cout << ans << "\n";
  }
  time();
  return 0;
}
