#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int c[3 * N];
int64_t dp[3 * N];
int main() {
  int n, i, x, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    c[x]++;
  }
  int pmax = 3000000;
  for (i = 1; i * i <= pmax; i++) {
    if (!c[i]) continue;
    for (j = 0; i * (i + j) < pmax; j++) {
      if (j == 0)
        dp[i * (i + j) + 1] += 1LL * c[i] * (c[i] - 1);
      else
        dp[i * (i + j) + 1] += 2LL * c[i] * c[i + j];
    }
  }
  for (i = 1; i <= pmax; i++) dp[i] += dp[i - 1];
  int m, p;
  scanf("%d", &m);
  while (m--) {
    scanf("%d", &p);
    printf("%I64d\n", 1LL * n * (n - 1) - dp[p]);
  }
}
