#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n];
  for (int i = 0; i <= n - 1; i++) {
    cin >> x[i];
  }
  sort(x, x + n);
  int q;
  cin >> q;
  int m[q];
  for (int i = 0; i <= q - 1; i++) {
    cin >> m[i];
  }
  for (int i = 0; i <= q - 1; i++) {
    int s = n / 2;
    if (x[s] > m[i]) {
      while ((x[s] > m[i]) && (s >= 0)) {
        s--;
      }
      cout << s + 1 << "\n";
    } else {
      while ((x[s] <= m[i]) && (s <= n - 1)) {
        s++;
      }
      cout << s << "\n";
    }
  }
}
