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