#include <bits/stdc++.h>
using namespace std;
int a[100010];
int n, m, x;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &x);
    printf("%d\n", upper_bound(a + 1, a + n + 1, x) - a - 1);
  }
  return 0;
}
