#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e6 + 10;
long long a[maxn], sum[maxn], n, m, big = 0, tmp;
int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &m);
    a[m]++;
    big = max(big, m);
  }
  for (int i = 0; i <= big; i++) {
    for (int j = 0; j <= big; j++) {
      if ((long long)i * j > maxn - 10) break;
      sum[i * j] += a[i] * a[j];
      if (i == j) sum[i * j] -= a[i];
    }
  }
  for (int i = 1; i < maxn; i++) sum[i] += sum[i - 1];
  scanf("%lld", &m);
  for (int i = 0; i < m; i++) {
    scanf("%lld", &tmp);
    printf("%lld\n", n * (n - 1) - sum[tmp - 1]);
  }
}
