#include <bits/stdc++.h>
using namespace std;
long long dp[3000006], cnt[3000006];
int main() {
  long long n;
  memset(dp, 0, sizeof dp);
  memset(cnt, 0, sizeof cnt);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d", &u);
    cnt[u]++;
  }
  int t = 3000000;
  for (int i = 1; i <= t; i++)
    for (int j = 1; j * i <= t; j++) {
      if (i != j)
        dp[i * j] += cnt[i] * cnt[j];
      else
        dp[i * j] += cnt[i] * (cnt[i] - 1);
    }
  for (int i = 1; i <= 3000000; i++) dp[i] += dp[i - 1];
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int u;
    scanf("%d", &u);
    long long p = n * (n - 1) - dp[u - 1];
    printf("%lld\n", p);
  }
  return 0;
}
