#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100, ma = 3e6 + 1, M = 3e6;
int t[3 * N], tp[3 * N], n;
long long ans[3 * N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int c;
    scanf("%d", &c);
    t[c]++;
  }
  for (int i = ma; i > -1; i--) tp[i] = t[i] + tp[i + 1];
  for (int i = 1; i < ma; i++) {
    if (!t[i]) continue;
    int e = M / i;
    for (int j = 1; j <= e; j++) {
      if (i == j)
        ans[i * i] += 1ll * t[i] * (t[i] - 1);
      else
        ans[i * j] += 1ll * t[i] * t[j];
    }
    if (e >= i)
      ans[ma] += 1ll * t[i] * tp[e + 1];
    else
      ans[ma] += 1ll * t[i] * (tp[e + 1] - 1);
  }
  for (int i = ma; i > -1; i--) {
    ans[i] += ans[i + 1];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int p;
    scanf("%d", &p);
    printf("%lld\n", ans[p]);
  }
}
