#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, q, val;
  int a, ans;
  cin >> n;
  vector<int> x;
  for (int i = 0; i < n; i++) {
    cin >> a;
    x.push_back(a);
  }
  cin >> q;
  sort(x.begin(), x.end());
  while (q--) {
    cin >> val;
    auto it = upper_bound(x.begin(), x.end(), val);
    if (it == x.end())
      ans = n;
    else {
      ans = it - x.begin();
    }
    cout << ans << endl;
  }
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  solve();
}
