#include <bits/stdc++.h>
using namespace std;
long long int n, m;
long long int h1[3000010], h2[3000010], a[1000010];
long long int myfind(long long int l, long long int h, long long int v) {
  long long int ans = -1, m;
  while (l <= h) {
    m = ((h - l) >> 1) + l;
    if ((v * a[m]) > 3000000) {
      ans = m;
      h = m - 1;
    } else
      l = m + 1;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(h1, 0, sizeof(h1));
  memset(h2, 0, sizeof(h2));
  cin >> n;
  long long int i, j, mc = 0;
  for (i = 0; i < n; i++) {
    cin >> j;
    a[i] = j;
    h1[j]++;
  }
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    j = myfind(i + 1, n - 1, a[i]);
    if (j != -1) mc += 2 * (n - j);
  }
  for (i = 1; i <= 3000000; i++) {
    for (j = 1; (j * i) <= 3000000; j++) {
      if (j == i) {
        h2[i * j] += h1[j] * (h1[j] - 1);
      } else {
        h2[i * j] += h1[j] * h1[i];
      }
    }
  }
  for (i = 1; i <= 3000000; i++) h2[i] += h2[i - 1];
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> j;
    cout << h2[3000000] - h2[j - 1] + mc << "\n";
  }
  return 0;
}
