#include <bits/stdc++.h>
using namespace std;
int b_search(vector<long long> &v, long long &x) {
  int low = 0, high = v.size();
  while (low < high) {
    int mid = low + (high - low) / 2;
    if (v[mid] <= x)
      low = mid + 1;
    else
      high = mid;
  }
  return low;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  long long nn;
  cin >> nn;
  for (long long i = 0; i < nn; i++) {
    long long x;
    cin >> x;
    cout << b_search(v, x) << endl;
  }
}
