#include <bits/stdc++.h>
using namespace std;
long long fr[3000005], n, m;
long long ans[3000005];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    fr[a]++;
  }
  for (int i = 1; i < 3000005; i++) {
    for (int j = i; j < 3000005; j += i) {
      ans[j] += fr[i] * fr[j / i];
      if (i * i == j) ans[j] -= fr[i];
    }
  }
  long long tot = n * (n - 1);
  for (int i = 1; i < 3000005; i++) ans[i] += ans[i - 1];
  cin >> m;
  while (m--) {
    int p;
    cin >> p;
    cout << tot - ans[p - 1] << "\n";
  }
}
