#include <bits/stdc++.h>
using namespace std;
const int N = 3e6;
long long f[N + 5], t;
int x, m, n, c[N + 5], s[N + 5];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (1LL * x * x <= N) f[x * x]--;
    c[x]++;
  }
  for (int i = 1; i <= N; i++)
    for (int j = i; j <= N; j += i) f[j] += 1LL * c[i] * c[j / i];
  for (int i = 1; i <= N; i++) f[i] += f[i - 1];
  for (int i = 1; i <= N; i++) s[i] = s[i - 1] + c[i];
  for (int i = 1; i <= N; i++) t += c[i] * (s[N] - s[N / i] - (i > (N / i)));
  cin >> m;
  for (int i = 1; i <= m; i++)
    scanf("%d", &x), printf("%I64d\n", f[N] - f[x - 1] + t);
}
