#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<long long> cc(3000001, 0);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    cc[a]++;
  }
  vector<long long> ma(3000001, 0);
  for (int i = 1; i <= 3000000; i++)
    for (int j = 1; i * j <= 3000000; j++)
      if (i == j)
        ma[i * j] += cc[i] * (cc[j] - 1);
      else
        ma[i * j] += cc[i] * cc[j];
  vector<long long> sma(3000001, 0);
  long long sm = 0;
  for (int i = 1; i <= 3000000; i++) {
    sm += ma[i];
    sma[i] = sm;
  }
  int m;
  scanf("%d", &m);
  int p;
  long long ll = ((long long)n) * (n - 1);
  for (int i = 0; i < m; i++) {
    scanf("%d", &p);
    printf("%I64d\n", ll - sma[p - 1]);
  }
  return 0;
}
