#include <bits/stdc++.h>
using namespace std;
const int MaxS = 3e6;
int N, Q;
long long t[MaxS + 10], pr[MaxS + 10];
int main() {
  scanf("%d", &N);
  for (register int i = 1; i <= N; ++i) {
    int x;
    scanf("%d", &x);
    t[x]++;
  }
  for (register int i = 1; i <= MaxS; ++i)
    for (int j = i; j <= MaxS; j += i) {
      int d = j / i;
      if (d == i)
        pr[j] += t[i] * (t[i] - 1);
      else
        pr[j] += t[i] * t[d];
    }
  for (register int i = 1; i <= MaxS; ++i) pr[i] += pr[i - 1];
  long long g = (long long)N * (N - 1);
  scanf("%d", &Q);
  for (register int i = 1; i <= Q; ++i) {
    int x;
    scanf("%d", &x);
    printf("%I64d\n", g - pr[x - 1]);
  }
  return 0;
}
