#include <bits/stdc++.h>
using namespace std;
int n, x[100009];
int binsearch(int start, int end, int val) {
  int ans = -1;
  while (start <= end) {
    int mid = (start + end) / 2;
    if (x[mid] <= val) {
      ans = max(ans, mid);
      start = mid + 1;
    } else
      end = mid - 1;
  }
  return ans + 1;
}
int main() {
  int q;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  sort(x, x + n);
  cin >> q;
  while (q--) {
    int l;
    cin >> l;
    int ans = binsearch(0, n - 1, l);
    cout << ans << "\n";
  }
  return 0;
}
