#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long mod = 1000000007;
const long long N = 3e6 + 10;
long long dd[N];
long long dp[N];
long long pref[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long c = 0; c < n; c++) {
    long long e;
    cin >> e;
    dd[e]++;
  }
  for (long long c = 1; c < N; c++) {
    for (long long i = c; i < N; i += c) {
      if (c == i / c)
        dp[i] += dd[c] * (dd[c] - 1);
      else
        dp[i] += dd[c] * dd[i / c];
    }
  }
  for (long long i = 1; i < N; i++) {
    pref[i] = pref[i - 1] + dp[i - 1];
  }
  long long q;
  cin >> q;
  long long all = n * (n - 1);
  for (long long c = 0; c < q; c++) {
    long long e;
    cin >> e;
    cout << all - pref[e] << '\n';
  }
  return 0;
}
