#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 3e6 + 1;
long long d[SIZE], c[SIZE];
int main() {
  int(n);
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    int(x);
    scanf("%d", &x);
    d[x]++;
  }
  for (int i = (1); i < (SIZE); ++i) {
    if (i * (long long)i < SIZE) c[i * i] += d[i] * (d[i] - 1);
    for (int j = i + 1; (long long)j * i < SIZE; j++)
      c[i * j] += 2 * d[i] * d[j];
    c[i] += c[i - 1];
  }
  long long A = n * (n - 1LL);
  int(Q);
  scanf("%d", &Q);
  for (int I = 0; I < (Q); ++I) {
    int(x);
    scanf("%d", &x);
    printf("%I64d ", A - c[x - 1]);
  }
  return 0;
}
