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