#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 3000100, LOG = 20;
long long n, m, k, u, v, x, y, t, a, b;
long long ans[MAXN];
long long cnt[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x, cnt[x]++;
  for (int i = 1; i < MAXN; i++)
    for (int j = 1; i * j < MAXN; j++)
      if (i != j) ans[i * j] += cnt[i] * cnt[j];
  for (int i = 1; i * i < MAXN; i++) ans[i * i] += cnt[i] * (cnt[i] - 1);
  for (int i = 1; i < MAXN; i++) ans[i] += ans[i - 1];
  cin >> m;
  while (m--) {
    cin >> x;
    cout << n * (n - 1) - ans[x - 1] << '\n';
  }
  return 0;
}
