#include <bits/stdc++.h>
using namespace std;
long long n, m, cnt[3000100], a[3000100], pre[3000100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  for (int i = 1; i < 3000100; i++) {
    for (int j = i; j < 3000100; j += i) {
      if (j == i * i)
        a[j] += cnt[i] * (cnt[i] - 1);
      else
        a[j] += cnt[i] * cnt[j / i];
    }
  }
  for (int i = 1; i < 3000100; i++) {
    pre[i] = a[i] + pre[i - 1];
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    printf("%lld\n", n * (n - 1) - pre[x - 1]);
  }
}
