#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 123;
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
int n, a[N], q, m[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &m[i]);
  }
  for (int i = 1; i <= q; i++) {
    int l = 0, r = n;
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      if (a[mid] > m[i])
        r = mid;
      else
        l = mid;
    }
    if (a[r] <= m[i]) l = r;
    printf("%d\n", l);
  }
  return 0;
}
