#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, x;
  vector<int> v;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  cin >> q;
  while (q--) {
    cin >> x;
    int ans = upper_bound(v.begin(), v.end(), x) - v.begin();
    cout << ans << endl;
  }
}
