#include <bits/stdc++.h>
using namespace std;
const long long N = 3e6 + 5;
const long long M = 3e6;
long long F[N], cnt[N], arr[N];
long long q, x, n;
signed main() {
  scanf("%lld", &n);
  for (long long i = 0; i < n; ++i) scanf("%lld", arr + i);
  sort(arr, arr + n);
  for (long long i = 0; i < n; ++i) F[arr[i]]++;
  for (long long i = N - 1; i; --i) F[i - 1] += F[i];
  for (long long i = 1; i < N; ++i) {
    long long mult = 1;
    long long sq = i * i;
    long long ff = F[i] - F[i + 1];
    if (!ff) continue;
    for (long long j = i; j <= M; j += i, mult++) {
      long long f = F[mult] - F[mult + 1];
      long long add = 0;
      if (j != sq)
        add = f * ff;
      else {
        add = f * (f - 1);
      }
      cnt[j] += add;
    }
    long long add = F[mult] * ff - ff * (mult <= i);
    cnt[N - 1] += add;
  }
  for (long long i = N - 1; i; --i) cnt[i - 1] += cnt[i];
  scanf("%lld", &q);
  while (q--) {
    scanf("%lld", &x);
    printf("%lld\n", cnt[x]);
  }
  return 0;
}
