#include <bits/stdc++.h>
using namespace std;
long long n, q, a[3000000 + 5], m[3000000 + 5], dp[3000000 + 5];
inline long long read() {
  long long q = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (isdigit(ch)) q = (q << 3) + (q << 1) + (ch ^ 48), ch = getchar();
  return f ? q : -q;
}
inline void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + 48);
}
signed main() {
  n = read();
  for (register long long i = 1; i <= n; ++i) a[i] = read(), ++m[a[i]];
  for (register long long i = 1; i <= 3000000; ++i)
    if (m[i])
      for (register long long j = i; j <= 3000000; j += i)
        dp[j] += m[i] * ((i ^ (j / i)) ? m[j / i] : m[i] - 1);
  for (register long long i = 1; i <= 3000000; ++i) dp[i] += dp[i - 1];
  q = read();
  while (q--) {
    long long x = read();
    print(n * (n - 1) - dp[x - 1]), putchar('\n');
  }
  return 0;
}
