#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long q;
  cin >> q;
  while (q--) {
    long long m;
    cin >> m;
    std::vector<long long>::iterator upper1;
    upper1 = std::upper_bound(a.begin(), a.end(), m);
    long long pos = upper1 - a.begin() - 1;
    if (a[pos] <= m)
      cout << pos + 1 << "\n";
    else
      cout << "0\n";
  }
  return 0;
}
