#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, long long int e) {
  if (e == 0) return 1;
  long long int x = powmod(a * a % 1000000007, e >> 1);
  return e & 1 ? x * a % 1000000007 : x;
}
const long long int N = 3 * (long long int)1000001;
long long int cnt[N], z[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    cnt[x]++;
  }
  for (long long int no = 1; no < N; no++)
    if (cnt[no])
      for (long long int j = 1; no * j < N; j++)
        if (no == j)
          z[no * j] += cnt[no] * (cnt[j] - 1);
        else
          z[no * j] += (cnt[no] * cnt[j]);
  for (long long int i = 1; i < N; i++) z[i] += z[i - 1];
  long long int m;
  cin >> m;
  while (m--) {
    long long int p;
    cin >> p;
    cout << n * (n - 1) - z[p - 1] << "\n";
  }
}
