#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int dummy;
    cin >> dummy;
    a.push_back(dummy);
  }
  cin >> q;
  sort(a.begin(), a.end());
  for (int i = 0; i < q; i++) {
    int w;
    cin >> w;
    auto ww = upper_bound(a.begin(), a.end(), w);
    cout << (ww - a.begin()) << endl;
  }
  return 0;
}
