#include <bits/stdc++.h>
static const int MAXN = 1e6 + 4;
static const int MAXP = 3e6 + 4;
int n, q, p;
int ct[MAXP];
long long cp[MAXP] = {0};
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &q);
    ++ct[q];
  }
  for (int i = 1; i < MAXP; ++i) {
    for (int j = 1; (long long)i * j < MAXP; ++j) {
      if (j == i)
        cp[i * j] += (long long)ct[i] * (ct[i] - 1);
      else
        cp[i * j] += (long long)ct[i] * ct[j];
    }
  }
  for (int i = 1; i < MAXP; ++i) cp[i] += cp[i - 1];
  scanf("%d", &q);
  do {
    scanf("%d", &p);
    printf("%I64d\n", (long long)n * (n - 1) - cp[p - 1]);
  } while (--q);
  return 0;
}
