#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const int MAXX = 3e6;
int N, M;
int B[MAXX + 5];
long long ans[MAXX + 5], sum[MAXX + 5];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    int in;
    scanf(" %d", &in);
    ++B[in];
  }
  for (int i = MAXX - 1; i > 0; --i) sum[i] = sum[i + 1] + B[i];
  for (int i = 1; i <= MAXX; ++i) {
    int max_k = 0;
    for (int j = i; j <= MAXX; j += i) {
      int k = j / i;
      max_k = k;
      if (k == i)
        ans[j] += 1LL * B[i] * (B[i] - 1);
      else
        ans[j] += 1LL * B[i] * B[k];
    }
    ++max_k;
    ans[MAXX + 1] += 1LL * B[i] * (max_k > i ? sum[max_k] : sum[max_k] - 1);
  }
  for (int i = MAXX; i > 0; --i) ans[i] += ans[i + 1];
  scanf(" %d", &M);
  while (M--) {
    int in;
    scanf(" %d", &in);
    printf("%I64d\n", ans[in]);
  }
}
