#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int M = 3000005;
int n, m;
long long cnt[M], dp[M], ans[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int i = 1; i * i < M; i++) {
    dp[i * i] += cnt[i] * (cnt[i] - 1);
    for (int j = i * i + i, mul = i + 1; j < M; j += i, mul++) {
      dp[j] += cnt[i] * cnt[mul] * 2;
    }
  }
  for (int i = 1; i < M; i++) dp[i] += dp[i - 1];
  scanf("%d", &m);
  long long tot = 1LL * n * (n - 1);
  for (int i = 0; i < m; i++) {
    int p;
    scanf("%d", &p);
    ans[i] = tot - dp[p - 1];
  }
  for (int i = 0; i < m; i++) printf("%I64d\n", ans[i]);
  return 0;
}
