#include <bits/stdc++.h>
using namespace std;
long long int ar[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int n, m;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    long long int y;
    cin >> y;
    ar[y]++;
  }
  ar[0] = 0;
  for (long long int i = 1; i < 100005; i++) {
    ar[i] += ar[i - 1];
  }
  cin >> m;
  for (long long int i = 0; i < m; i++) {
    long long int x;
    cin >> x;
    if (x >= 100000)
      cout << ar[100004] << "\n";
    else
      cout << ar[x] << "\n";
  }
  return 0;
}
