#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  cin >> q;
  for (int j = 0; j < q; j++) {
    int l = 0, r = n - 1;
    int now;
    cin >> now;
    int ans = -1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (a[mid] <= now) {
        ans = max(ans, mid);
        l = mid + 1;
      } else
        r = mid - 1;
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
