#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int q;
  cin >> q;
  for (int j = 0; j < q; j++) {
    int t;
    cin >> t;
    int l = 0;
    int r = n - 1;
    int m = (l + r) / 2;
    while (r - l > 1) {
      m = (l + r) / 2;
      if (t >= A[m])
        l = m;
      else
        r = m;
    }
    if (A[r] <= t)
      cout << r + 1 << '\n';
    else if (A[l] <= t)
      cout << l + 1 << '\n';
    else
      cout << l << '\n';
  }
}
