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