#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 18;
int n, cnt[3 * N];
unsigned long long res[3 * N], sum[3 * N];
vector<int> a;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  long long fuk = 1LL * n * (n - 1);
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  for (int i = 0; i < a.size(); i++) {
    int k = 1;
    while (1LL * a[i] * k < 3 * N) {
      int z = cnt[k];
      if (k == a[i]) z--;
      res[a[i] * k] += 1LL * cnt[a[i]] * z;
      k++;
    }
  }
  for (int i = 1; i < 3 * N; i++) sum[i] = sum[i - 1] + res[i];
  int m;
  cin >> m;
  while (m--) {
    int p;
    cin >> p;
    long long resu = fuk - sum[p - 1];
    printf("%I64d\n", resu);
  }
}
