#include <bits/stdc++.h>
using namespace std;
int n, x, q, v[3000006];
long long ans, cnt[3000006], T[3000006], R[3000006], seen[3000006];
set<int> S;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x), v[x]++, cnt[x]++, S.insert(x);
  for (int i = 1; i <= 3000006 - 6; i++) v[i] += v[i - 1];
  for (int i = 2; i <= 1732; i++) {
    if (cnt[i]) {
      auto j = S.upper_bound(i);
      while (j != S.end()) {
        int r = *j;
        long long j1 = cnt[i] * 1LL * cnt[r] * 2LL;
        if (i * r > 3000006 - 6) {
          R[3000006 - 6] += cnt[i] * 2LL * (v[3000006 - 6] - v[r - 1]);
          R[max(i * i, r)] -= cnt[i] * 2LL * (v[3000006 - 6] - v[r - 1]);
          break;
        }
        T[min(i * r + 1, 3000006 - 6)] -= j1;
        T[max(i * i + 1, r + 1)] += j1;
        j++;
      }
    }
  }
  for (int i = 1; i <= 3000006 - 6; i++) T[i] += T[i - 1];
  for (int i = 3000006 - 6; i > 0; i--) R[i] += R[i + 1];
  scanf("%d", &q);
  while (q--) {
    ans = 0;
    scanf("%d", &x);
    if (seen[x] != 0) {
      printf("%lld\n", seen[x]);
      continue;
    }
    long long j = v[3000006 - 6] - v[x - 1];
    ans += (j - 1) * 1LL * j;
    ans += (n - j) * 2LL * j;
    long long sq = sqrt(x);
    if (sq * sq < x) sq++;
    j = v[x - 1] - v[sq - 1];
    ans += (j - 1) * 1LL * j;
    ans += T[x] + R[x];
    printf("%lld\n", ans);
    seen[x] = ans;
  }
}
