#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
long long a[1000005], n;
long long freq[3000005], mul[3000005];
vector<pair<long long, long long>> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long q, m, k, h, ans = 0, sum = 0, p, x, y;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++freq[a[i]];
  }
  for (int i = 1; i < 3000005; ++i)
    if (freq[i]) v.emplace_back(i, freq[i]);
  for (int i = 0; i < v.size(); ++i) {
    for (int j = 0; j < v.size(); ++j) {
      if (v[i].first * v[j].first >= 3000005) break;
      mul[v[i].first * v[j].first] += v[i].second * (v[j].second - (i == j));
    }
  }
  for (int i = 1; i < 3000005; ++i) mul[i] += mul[i - 1];
  for (cin >> q; q--; cout << n * (n - 1) - mul[p - 1] << '\n') cin >> p;
}
