#include <bits/stdc++.h>
using namespace std;
int getint() {
  int ans(0);
  char w = getchar();
  while (w < '0' || '9' < w) w = getchar();
  while ('0' <= w && w <= '9') {
    ans = ans * 10 + w - '0';
    w = getchar();
  }
  return ans;
}
int upper_bo(int* a, int left, int right, int key) {
  int middle;
  while (left <= right) {
    middle = (left + right) / 2;
    if (a[middle] > key)
      right = middle - 1;
    else
      left = middle + 1;
  }
  return right;
}
int main() {
  int n, q;
  n = getint();
  int* a = new int[n];
  for (int i = 0; i < n; i++) a[i] = getint();
  sort(a, a + n);
  cin >> q;
  while (q--) printf("%d\n", upper_bo(a, 0, n - 1, getint()) + 1);
  return 0;
}
