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