#include <bits/stdc++.h>
using namespace std;
unordered_map<int, long long> a;
vector<long long> nums;
long long ans[3000000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
    nums.push_back(x);
  }
  sort(nums.begin(), nums.end());
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
  for (int i = 0; i < nums.size(); i++) {
    if (nums[i] * nums[i] < 3000000) {
      ans[nums[i] * nums[i]] += a[nums[i]] * (a[nums[i]] - 1) / 2;
      for (int j = i + 1; j < nums.size(); j++) {
        if (nums[i] * nums[j] < 3000000)
          ans[nums[i] * nums[j]] += a[nums[i]] * a[nums[j]];
        else
          break;
      }
    } else
      break;
  }
  for (int i = 1; i < 3000000; i++) ans[i] += ans[i - 1];
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    cout << n * (n - 1) - 2 * ans[k - 1] << "\n";
  }
}
