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