#include <bits/stdc++.h>
using namespace std;
int q;
int n = (int)(1e5 + 5);
int a[(int)(1e5 + 5)];
long long b[(int)(1e5 + 5)];
int binary(int num) {
  int low = 0;
  int high = n - 1;
  int mid;
  int ans = -1;
  while (low <= high) {
    mid = (low + high) / 2;
    if (num >= a[mid]) {
      ans = mid;
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  return ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> b[i];
  }
  sort(a, a + n);
  for (int i = 0; i < q; i++) {
    cout << binary(b[i]) + 1 << endl;
  }
  return 0;
}
