#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, m;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  cin >> q;
  while (q--) {
    cin >> m;
    cout << upper_bound(a, a + n, m) - a << endl;
  }
}
