#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b;
int say[3000001];
long long ans[3000001], curans, az[3000001];
int main() {
  scanf("%d", &n);
  curans = 1LL * n * (n - 1);
  ans[1] = curans;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a);
    say[a]++;
  }
  for (int i = 1; i < 3000001; ++i)
    for (int j = i; j < 3000001; j += i) {
      if (i != j / i)
        az[j] = az[j] + 1LL * say[i] * say[j / i];
      else
        az[j] = az[j] + 1LL * say[i] * (say[j / i] - 1);
    }
  for (int i = 1; i < 3000000; ++i) {
    curans -= az[i];
    ans[i + 1] = curans;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &b);
    printf("%I64d\n", ans[b]);
  }
  return 0;
}
