#include <bits/stdc++.h>
using namespace std;
const int N = 3333333;
int cnt[N], sum[N];
long long ans[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int i = N - 2; i >= 1; i--) sum[i] = sum[i + 1] + cnt[i];
  for (int i = 1; i < N - 1; i++)
    if (cnt[i]) {
      int j;
      for (j = 1; i * j < N - 1; j++)
        ans[i * j] +=
            i != j ? 1LL * cnt[i] * cnt[j] : 1LL * cnt[i] * (cnt[i] - 1);
      if (j <= i)
        ans[N - 1] += 1LL * cnt[i] * sum[j] - cnt[i];
      else
        ans[N - 1] += 1LL * cnt[i] * sum[j];
    }
  for (int i = N - 2; i >= 1; i--) ans[i] += ans[i + 1];
  assert(ans[1] == 1LL * n * (n - 1));
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int x;
    scanf("%d", &x);
    printf("%I64d\n", ans[x]);
  }
  return 0;
}
