#include <bits/stdc++.h>
using namespace std;
const int A = 3000001;
int n, q, cnt[A];
long long p[A];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0, x; i < n && cin >> x; i++) cnt[x]++;
  for (int i = 1; i < A; i++) {
    for (int j = 1; i * j < A; j++) {
      if (i == j)
        p[i * j] += 1LL * cnt[i] * (cnt[i] - 1);
      else
        p[i * j] += 1LL * cnt[i] * cnt[j];
    }
  }
  for (int i = 1; i < A; i++) {
    p[i] += p[i - 1];
  }
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    cout << 1LL * n * (n - 1) - p[x - 1] << '\n';
  }
}
