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