#include <bits/stdc++.h>
using namespace std;
vector<long long> x;
string s;
string ans = "";
long long dp[3000002];
long long freq[3000001];
int main() {
  int n, c;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &c);
    freq[c]++;
    x.push_back(c);
  }
  sort(x.begin(), x.end());
  long long all = 0;
  for (int i = 0; i < x.size(); i++) {
    long long l = 0, r = 1e9, mid, best = 1e9, s;
    while (l <= r) {
      mid = (l + r) / 2;
      if (mid * x[i] > 3000000) {
        r = mid - 1;
        best = mid;
      } else
        l = mid + 1;
    }
    s = best;
    all += x.end() - lower_bound(x.begin(), x.end(), s);
    if (s <= x[i]) all--;
  }
  for (int i = 1; i <= 3000000; i++) {
    for (int j = i; j <= 3000000; j += i) {
      int div2 = j / i;
      if (div2 == i)
        dp[j] += freq[i] * (freq[i] - 1);
      else
        dp[j] += freq[i] * (freq[div2]);
    }
  }
  for (int i = 3000000; i > 0; i--) {
    dp[i] += dp[i + 1];
  }
  int q, w;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &w);
    printf("%lld\n", dp[w] + all);
  }
  return 0;
}
