#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 3e6 + 10;
long long mp[N], ans[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    mp[x]++;
  }
  for (long long i = 1; i <= 3000000; i++) {
    for (long long j = 1; j * i <= 3000000; j++) {
      if (i == j) {
        ans[i * i] += mp[i] * (mp[i] - 1);
      } else {
        ans[i * j] += mp[i] * mp[j];
      }
    }
  }
  for (long long i = 1; i <= 3000000; i++) {
    ans[i] += ans[i - 1];
  }
  long long m;
  cin >> m;
  for (long long i = 1; i <= m; i++) {
    long long x;
    cin >> x;
    cout << n * (n - 1) - ans[x - 1] << "\n";
  }
}
