#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int cnt[3000001];
long long res[3000001];
int main() {
  int n, m;
  scanf("%d", &n);
  for (int(i) = (1); (i) <= (n); (i) += (1)) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int(i) = (1); (i) <= (3000000); (i) += (1)) {
    if (!cnt[i]) continue;
    for (int(j) = (i); (j) <= (3000000); (j) += (i)) {
      if (j / i == i)
        res[j] += (long long)cnt[i] * (cnt[i] - 1);
      else
        res[j] += (long long)cnt[i] * cnt[j / i];
    }
  }
  for (int(i) = (1); (i) <= (3000000); (i) += (1)) res[i] += res[i - 1];
  scanf("%d", &m);
  long long ori = (long long)n * (n - 1);
  while (m--) {
    int x;
    scanf("%d", &x);
    printf("%lld\n", ori - res[x - 1]);
  }
}
