#include <bits/stdc++.h>
using namespace std;
int main() {
  int shopin;
  vector<int> shop;
  int price;
  int day;
  int money;
  cin >> shopin;
  for (int i = 1; i <= shopin; i++) {
    cin >> price;
    shop.push_back(price);
  }
  sort(shop.begin(), shop.begin() + shop.size());
  cin >> day;
  for (int i = 1; i <= day; i++) {
    cin >> money;
    int L = -1, R = shopin;
    while (R - L > 1) {
      if (money >= shop[(R + L) / 2]) {
        L = (R + L) / 2;
      } else {
        R = (R + L) / 2;
      }
    }
    cout << L + 1 << endl;
  }
  return 0;
}
