#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], i;
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int q, b, j, c;
  cin >> q;
  int first, last, mid;
  for (i = 0; i < q; i++) {
    scanf("%d", &b);
    c = -1;
    first = 0;
    last = n - 1;
    while (first <= last) {
      mid = (first + last) / 2;
      if (a[mid] == b) {
        c = mid;
        first = mid + 1;
      } else if (a[mid] > b)
        last = mid - 1;
      else
        first = mid + 1;
    }
    if (c == -1) c = first - 1;
    printf("%d\n", c + 1);
  }
}
