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