#include <bits/stdc++.h>
using namespace std;
long long cnt[3000005];
long long w[3000005];
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int i = 1; i <= 3000000; i++) {
    int j = 1;
    int k = i * j;
    while (k <= 3000000) {
      if (i != j)
        w[k] += cnt[i] * cnt[j];
      else
        w[k] += cnt[i] * (cnt[i] - 1);
      j++;
      k = i * j;
    }
  }
  for (int i = 1; i <= 3000000; i++) {
    w[i] += w[i - 1];
  }
  long long t = (long long)n * (long long)(n - 1);
  int q;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &x);
    printf("%lld\n", t - w[x - 1]);
  }
  return 0;
}
