#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> s(n);
  for (long long i = 0; i < n; i++) cin >> s[i];
  sort((s).begin(), (s).end());
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long temp;
    cin >> temp;
    long long l = 0, r = n;
    while (l < r) {
      long long mid = (l + r) / 2;
      if (s[mid] <= temp)
        l = mid + 1;
      else
        r = mid;
    }
    cout << l << endl;
  }
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n = 1;
  for (long long i = 0; i < n; i++) solve();
  return 0;
}
