#include <bits/stdc++.h>
const int MAX_PRICE = 100000;
int main() {
  int n;
  scanf("%d", &n);
  int *X = new int[n];
  for (int i = 0; i < n; i++) scanf("%d", X + i);
  std::sort(X, X + n);
  int *Qty = new int[MAX_PRICE + 1];
  int index = 0;
  for (int i = 0; i <= MAX_PRICE; i++) {
    while (index < n && X[index] == i) index++;
    Qty[i] = index;
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int m;
    scanf("%d", &m);
    if (m > MAX_PRICE)
      printf("%d\n", Qty[MAX_PRICE]);
    else
      printf("%d\n", Qty[m]);
  }
  delete[] Qty;
  delete[] X;
  return 0;
}
