#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v, y;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    v.push_back(val);
  }
  sort(v.begin(), v.end());
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int val;
    cin >> val;
    y.push_back(val);
  }
  for (int i = 0; i < q; i++) {
    if (y[i] >= v[n - 1])
      cout << n;
    else if (y[i] < v[0])
      cout << 0;
    else {
      vector<int>::iterator it = upper_bound(v.begin(), v.end(), y[i]);
      cout << it - v.begin();
    }
    if (i != q - 1) cout << endl;
  }
  return 0;
}
