#include <bits/stdc++.h>
using namespace std;
int p[3000100];
long long sum[3000100];
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    p[x]++;
  }
  for (int i = 1; i <= 3000100; i++) {
    if (p[i] == 0) continue;
    for (int j = 1; j * i <= 3000100; j++) {
      sum[i * j] += 1ll * p[i] * p[j];
      if (i == j) sum[i * j] -= p[i];
    }
  }
  for (int i = 1; i <= 3000100; i++) sum[i] += sum[i - 1];
  scanf("%d", &m);
  long long cnt = 1ll * n * (n - 1);
  while (m--) {
    int x;
    scanf("%d", &x);
    printf("%lld\n", cnt - sum[x - 1]);
  }
  return 0;
}
