#include <bits/stdc++.h>
using namespace std;
const int N = 3000001;
int n, m, freq[N];
long long cum[N];
int main(int argc, char **argv) {
  scanf("%d", &n);
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    ++freq[x];
  }
  for (int i = 1; i < N; ++i) {
    if (!freq[i]) continue;
    for (int j = i; j < N; j += i)
      if (1LL * i * i == j)
        cum[j] += 1LL * freq[i] * (freq[i] - 1);
      else
        cum[j] += 1LL * freq[i] * freq[j / i];
  }
  for (int i = 1; i < N; ++i) cum[i] += cum[i - 1];
  long long all = 1LL * n * (n - 1);
  scanf("%d", &m);
  while (m--) {
    int p;
    scanf("%d", &p);
    printf("%lld\n", all - cum[p - 1]);
  }
  return 0;
}
