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