#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, a, b;
  cin >> t;
  vector<long long> v(t);
  for (long long i = 0; i < t; i++) cin >> v[i];
  sort(v.begin(), v.end());
  cin >> a;
  for (long long i = 0; i < a; i++) {
    cin >> b;
    auto u = upper_bound(v.begin(), v.end(), b);
    if (u == v.end())
      cout << t << "\n";
    else
      cout << (u - v.begin()) << "\n";
  }
}
