#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 7;
long long cnt[N];
long long pre[N];
int m;
int n, x;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int i = 1; i < N; ++i)
    if (cnt[i]) {
      for (int j = i; j < N; j += i) {
        if (i != j / i)
          pre[j] += cnt[i] * cnt[j / i];
        else
          pre[j] += (cnt[i] - 1) * cnt[i];
      }
    }
  for (int i = 1; i < N; ++i) pre[i] += pre[i - 1];
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &x);
    long long ans = (long long)n * (n - 1) - pre[x - 1];
    printf("%I64d\n", ans);
  }
}
