#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int N = 3000031;
int n, ar[N];
int cnt[N];
long long total[N], below[N];
int tests, val;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    cnt[ar[i]]++;
  }
  for (int i = 1; i <= 3000000; i++) {
    if (cnt[i] == 0) continue;
    for (int j = 1; j * i <= 3000000; j++) {
      total[i * j] += 1ll * cnt[i] * cnt[j];
      if (i == j) total[i * j] -= cnt[i];
    }
  }
  for (int i = 1; i <= 3000000; i++) {
    below[i] = below[i - 1] + total[i - 1];
  }
  long long RES = 1ll * n * (n - 1);
  cin >> tests;
  for (; tests; --tests) {
    cin >> val;
    cout << RES - below[val] << "\n";
  }
  cin.get();
  cin.get();
  return 0;
}
