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