#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int maxn = 3100000;
long long cnt[maxn], cnt2[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i], ++cnt[a[i]];
  for (int i = 1; i <= (int)(maxn - 1); ++i)
    for (int j = 1; i * j < maxn; ++j) {
      if (i == j)
        cnt2[i * j] += cnt[i] * (cnt[j] - 1);
      else
        cnt2[i * j] += cnt[i] * cnt[j];
    }
  for (int i = 0; i < (int)(maxn - 1); ++i) cnt2[i + 1] += cnt2[i];
  int m;
  cin >> m;
  for (int i = 0; i < (int)(m); ++i) {
    int x;
    cin >> x;
    cout << 1LL * n * (n - 1) - cnt2[x - 1] << '\n';
  }
  return 0;
}
