#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e6 + 10;
const long long INF = 1e18;
long long power(long long x, long long n) {
  long long t = 1;
  while (n) {
    if (n % 2)
      t = x * t % mod, n--;
    else
      n /= 2, x = x * x % mod;
  }
  return t;
}
int arr[N];
long long sum[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int c;
    scanf("%d", &c);
    arr[c]++;
  }
  for (int i = 1; i < 2001; ++i)
    if (arr[i]) {
      for (int j = i, k = i * i; k < N; k += i, j++) {
        if (j == i)
          sum[k] += (arr[i] - 1) * arr[i] / 2;
        else
          sum[k] += arr[i] * arr[j];
      }
    }
  for (int i = 1; i < N; ++i) sum[i] += sum[i - 1];
  int q;
  scanf("%d", &q);
  while (q--) {
    long long ans = 1ll * n * (n - 1);
    int p;
    scanf("%d", &p);
    ans -= 2 * sum[p - 1];
    printf("%lld\n", ans);
  }
  return 0;
}
