#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("O2")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long int N = 3e6 + 10, mod = 2e18, inf = 1e18;
int cnt[N], a[N], c[N];
long long pre[N];
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 1; i < N; i++) {
    for (long long j = 1; j * i < N; j++) {
      int r = min(1ll * N - 2, i * j);
      if (i == j)
        c[r] += 1ll * cnt[j] * (cnt[j] - 1);
      else
        c[r] += 1ll * cnt[i] * cnt[j];
    }
  }
  for (int i = 1; i < N - 2; i++) pre[i] = pre[i - 1] + c[i];
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p;
    cout << 1ll * n * (n - 1) - pre[p - 1] << '\n';
  }
}
