#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  vector<int> v;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int m;
    cin >> m;
    if (v[n - 1] < m)
      cout << n << endl;
    else {
      int res = upper_bound(v.begin(), v.end(), m) - v.begin();
      cout << res << endl;
    }
  }
  return 0;
}
