#include <bits/stdc++.h>
using namespace std;
long long M[3000001];
long long S[3000001];
long long n, m, maxx;
int main() {
  cin >> n;
  for (long long i = 0, x = 0; i != n; ++i) {
    scanf("%lld", &x);
    ++M[x];
    maxx = max(maxx, x);
  }
  for (long long i = 0; i <= maxx; ++i) {
    for (long long j = 0; j <= maxx; ++j) {
      if (i * j > 3 * (1e6))
        break;
      else {
        S[i * j] += M[i] * M[j];
        if (i == j) S[i * j] -= M[i];
      }
    }
  }
  cin >> m;
  for (long long i = 1; i <= 3 * (1e6); ++i) S[i] += S[i - 1];
  for (long long i = 0, p; i != m; ++i) {
    scanf("%lld", &p);
    printf("%lld\n", n * (n - 1) - S[p - 1]);
  }
  return 0;
}
