#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ar[100005], i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> ar[i];
  }
  sort(ar + 1, ar + n + 1);
  int q, s;
  cin >> q;
  while (q--) {
    cin >> s;
    int lo = 1, hi = n, mid, ans = 0;
    while (lo <= hi) {
      mid = (lo + hi) / 2;
      if (s >= ar[mid]) {
        lo = mid + 1;
        ans = mid;
      } else {
        hi = mid - 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
