#include <bits/stdc++.h>
using namespace std;
long bin_search(long *a, long n, long k) {
  long l, r, mid;
  l = 0;
  r = n;
  if (k < a[0]) {
    return -1;
  } else if (k >= a[n - 1]) {
    return (n - 1);
  }
  while (l <= r) {
    mid = (l + r) / 2;
    if (k >= a[mid] && k < a[mid + 1]) {
      return mid;
    } else if (k >= a[mid]) {
      l = mid;
    } else if (k < a[mid]) {
      r = mid;
    }
  }
  return mid;
}
int main() {
  long n, q, i;
  cin >> n;
  long x[n];
  for (i = 0; i < n; i++) {
    cin >> x[i];
  }
  cin >> q;
  long m[q];
  for (i = 0; i < q; i++) {
    cin >> m[i];
  }
  sort(x, x + n);
  long k;
  for (i = 0; i < q; i++) {
    k = (bin_search(x, n, m[i]));
    if (k == -1) {
      cout << "0" << endl;
    } else {
      cout << (k + 1) << endl;
    }
  }
  return 0;
}
