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