#include <bits/stdc++.h>
using namespace std;
using vint = vector<long long>;
using pint = pair<long long, long long>;
using vpint = vector<pint>;
template <typename A, typename B>
inline void chmin(A& a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A& a, B b) {
  if (a < b) a = b;
}
template <class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>& p) {
  ost << "{" << p.first << "," << p.second << "}";
  return ost;
}
template <class T>
ostream& operator<<(ostream& ost, const vector<T>& v) {
  ost << "{";
  for (long long i = 0; i < v.size(); i++) {
    if (i) ost << ",";
    ost << v[i];
  }
  ost << "}";
  return ost;
}
inline long long topbit(unsigned long long x) {
  return x ? 63 - __builtin_clzll(x) : -1;
}
inline long long popcount(unsigned long long x) {
  return __builtin_popcountll(x);
}
inline long long parity(unsigned long long x) { return __builtin_parity(x); }
const long long MAXV = 3000000;
long long N, Q;
long long A[1111111];
long long cnt[MAXV + 1];
long long ans[MAXV + 1];
signed main() {
  scanf("%lld", &N);
  for (long long i = 0; i < (N); i++) scanf("%lld", &A[i]);
  for (long long i = 0; i < (N); i++) cnt[A[i]]++;
  for (long long i = 1; i <= MAXV; i++) {
    for (long long j = 1; i * j <= MAXV; j++) {
      ans[i * j] += cnt[i] * cnt[j];
    }
  }
  for (long long i = 0; i < (N); i++)
    if (A[i] * A[i] <= MAXV) ans[A[i] * A[i]]--;
  for (long long i = 0; i < (MAXV); i++) ans[i + 1] += ans[i];
  scanf("%lld", &Q);
  for (long long i = 0; i < (Q); i++) {
    long long p;
    scanf("%lld", &p);
    long long tmp = N * (N - 1) - ans[p - 1];
    printf("%lld\n", tmp);
  }
  return 0;
}
