#include <bits/stdc++.h>
using namespace std;
int cnt[3000005];
long long ans[3000005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    ++cnt[x];
  }
  for (int i = 1; i <= 3000000; ++i) {
    if (!cnt[i]) continue;
    for (int j = i; j <= 3000000; j += i) ans[j] += 1LL * cnt[i] * cnt[j / i];
    if (1LL * i * i <= 3000000) ans[i * i] -= cnt[i];
  }
  for (int i = 1; i <= 3000000; ++i) ans[i] += ans[i - 1];
  long long sum = 1LL * n * (n - 1);
  int m;
  scanf("%d", &m);
  while (m--) {
    int x;
    scanf("%d", &x);
    printf("%lld\n", sum - ans[x - 1]);
  }
  return 0;
}
