#include <bits/stdc++.h>
using namespace std;
map<int, int> F;
const int nax = 3 * 1000000;
long long ans[3 * 1000000 + 6];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N, M, i, j;
  cin >> N;
  vector<int> A(N);
  for (i = 0; i < N; ++i) {
    cin >> A[i];
    F[A[i]]++;
  }
  long long NC2 = N * 1LL * (N - 1);
  for (auto it = F.begin(); it != F.end(); ++it)
    for (auto jt = F.begin(); jt != it; ++jt) {
      long long x = it->first;
      long long y = jt->first;
      long long add = (it->second) * 1LL * (jt->second);
      if (x * y > nax) break;
      ans[x * y] += 2 * add;
    }
  for (auto it = F.begin(); it != F.end(); ++it) {
    long long x = it->first;
    long long y = it->first;
    long long add = (it->second) * 1LL * (it->second - 1);
    if (x * y > nax) break;
    ans[x * y] += add;
  }
  for (i = nax; i > 0; --i) ans[i] += ans[i + 1];
  NC2 -= ans[1];
  cin >> M;
  int x;
  for (i = 0; i < M; ++i) {
    cin >> x;
    cout << ans[x] + NC2 << '\n';
  }
  return 0;
}
