#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
long long cnt[3000005], pre[3000005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  long long n;
  scanf("%lld", &n);
  long long a;
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a);
    cnt[a]++;
  }
  for (long long i = 1; i < 3000005; i++) {
    for (long long j = 1; i * j < 3000005; j++) {
      if (i == j)
        pre[i * j] += (cnt[i] * (cnt[i] - 1));
      else
        pre[i * j] += cnt[i] * cnt[j];
    }
  }
  for (long long i = 1; i < 3000005; i++) pre[i] += pre[i - 1];
  long long m, p, an = 0, tot = (n * (n - 1));
  scanf("%lld", &m);
  for (long long i = 0; i < m; i++) {
    scanf("%lld", &p);
    an = tot - pre[p - 1];
    printf("%lld\n", an);
  }
  return 0;
}
