#include <bits/stdc++.h>
using namespace std;
vector<int> G[2 * 100000 + 5];
signed long long int freq[3000000 + 5];
signed long long int ans[3000000 + 5];
signed long long int cum[3000000 + 5];
int main() {
  int N, M;
  cin >> N;
  for (int i = (1); i <= (N); ++i) {
    int x;
    scanf("%d", &x);
    freq[x]++;
  }
  for (int i = 3000000; i >= 1; i--) cum[i] = cum[i + 1] + freq[i];
  for (int i = (1); i <= (3000000); ++i) {
    int j;
    for (j = 1; j * 1LL * i <= 3000000; ++j) {
      ans[i * j] += freq[i] * (freq[j] - (i == j));
    }
    if (j <= 3000000) {
      int more = cum[j];
      if (j <= i) more--;
      ans[3000000 + 1] += freq[i] * more;
    }
  }
  for (int i = 3000000; i >= 1; i--) {
    ans[i] += ans[i + 1];
  }
  cin >> M;
  while (M--) {
    int p;
    scanf("%d", &p);
    printf("%lld\n", ans[p]);
  }
}
