#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000006], cnt[3000005], p;
long long f[3000005], res;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= n; i++) cnt[a[i]]++;
  for (int i = 1; i < 3000005; i++) {
    if (cnt[i] == 0) continue;
    for (int j = i; j < 3000005; j += i) {
      if (j / i != i)
        f[j] += 1ll * cnt[i] * cnt[j / i];
      else
        f[j] += cnt[i] * (cnt[i] - 1);
    }
  }
  for (int i = 1; i < 3000005; i++) f[i] += f[i - 1];
  scanf("%d", &m);
  while (m--) {
    scanf("%d", &p);
    res = 1ll * n * (n - 1) - f[p - 1];
    printf("%lld \n", res);
  }
  return 0;
}
