#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> x;
  for (int i = 1; i <= n; ++i) {
    int y;
    cin >> y;
    x.push_back(y);
  }
  sort(x.begin(), x.end());
  int q;
  cin >> q;
  while (q--) {
    int m;
    cin >> m;
    int t = m;
    vector<int>::iterator it;
    it = upper_bound(x.begin(), x.end(), m);
    int dr = it - x.begin();
    cout << dr << "\n";
  }
}
