#include <bits/stdc++.h>
using namespace std;
const long N = 3e6 + 6;
long cnt[N], a[N], b[N];
long long ways[N];
void preprocess(long n) {
  for (long i = 0; i < n; i++) cnt[a[i]]++;
  for (long i = 0; i < N; i++) {
    if (!cnt[i]) continue;
    for (long j = i; j < N; j += i) {
      if (j / i != i)
        ways[j] += (long long)cnt[i] * cnt[j / i];
      else
        ways[j] += (long long)cnt[i] * (cnt[i] - 1);
    }
  }
  for (long i = 1; i < N; i++) ways[i] += ways[i - 1];
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long n;
  cin >> n;
  for (long i = 0; i < n; i++) cin >> a[i];
  preprocess(n);
  long m;
  cin >> m;
  for (long i = 0; i < m; i++) cin >> b[i];
  for (long i = 0; i < m; i++) {
    long long ans;
    ans = (long long)n * (n - 1) - ways[b[i] - 1];
    cout << ans << '\n';
  }
  return 0;
}
