#include <bits/stdc++.h>
using namespace std;
mt19937_64 llrand((int)chrono::steady_clock::now().time_since_epoch().count());
const long long INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const long long N = 1e6 + 5;
const long long M = 3e6 + 5;
long long n, m, p;
long long a, cnt[M];
long long sum[M];
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a, cnt[a]++;
  for (long long i = 1; i < M; i++) {
    for (long long j = i; j < M; j += i)
      sum[j] += 1ll * cnt[i] * (cnt[j / i] - (j / i == i ? 1ll : 0ll));
  }
  for (long long i = 1; i < M; i++) sum[i] += sum[i - 1];
  cin >> m;
  while (m--) {
    cin >> p;
    cout << n * (n - 1) - sum[p - 1] << "\n";
  }
}
