#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q, num, n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  cin >> q;
  while (q--) {
    cin >> num;
    cout << upper_bound(arr, arr + n, num) - arr << endl;
  }
}
