#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long int dp[100000 + 5] = {0};
void fun(long long int *A, long long int N) {
  dp[0] = 0;
  long long int a = 0;
  for (long long int i = 1; i <= 100000; ++i) {
    while (a < N and A[a] <= i) ++a;
    dp[i] = a;
  }
}
void solve() {
  long long int N;
  cin >> N;
  long long int A[N];
  for (long long int i = 0; i < N; ++i) cin >> A[i];
  sort(A, A + N);
  fun(A, N);
  long long int Q;
  cin >> Q;
  while (Q--) {
    long long int M;
    cin >> M;
    if (M > 100000)
      cout << N << '\n';
    else
      cout << dp[M] << '\n';
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
  exit(0);
}
