#include <bits/stdc++.h>
using namespace std;
vector<unsigned long long int> vec;
int main() {
  unsigned long long int a, b, c = 0, inp;
  cin >> a;
  for (unsigned long long int q = 0; q < a; q++) {
    cin >> inp;
    vec.push_back(inp);
  }
  sort(vec.begin(), vec.end());
  cin >> b;
  vector<unsigned long long int>::iterator it, ito;
  for (unsigned long long int q = 0; q < b; q++) {
    cin >> inp;
    it = upper_bound(vec.begin(), vec.end(), inp);
    ito = it;
    ++it;
    unsigned long long int index = distance(vec.begin(), it);
    unsigned long long int index_2 = distance(vec.begin(), ito);
    if (*it <= inp && index < vec.size())
      cout << index;
    else
      cout << index_2;
    cout << endl;
  }
}
