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