#include <bits/stdc++.h>
using namespace std;
int v[100000], q[100000];
void qs(int a, int b) {
  int i, j, aux;
  cout << a << ' ' << b << '\n';
  if (a >= b) return;
  int pivot = v[b];
  j = a;
  for (i = a; i < b; i++) {
    if (v[i] < pivot) {
      aux = v[j];
      v[j] = v[i];
      v[i] = aux;
      j++;
    }
  }
  aux = v[j];
  v[j] = v[b];
  v[b] = aux;
  qs(a, j - 1);
  qs(j + 1, b);
}
int main() {
  int n, i, m, j, x, k;
  cin >> n;
  for (i = 0; i < n; i++) cin >> v[i];
  sort(v, v + n);
  cin >> m;
  for (j = 0; j < m; j++) {
    cin >> x;
    k = 1;
    while (k * 2 < n) {
      k *= 2;
    }
    i = 0;
    while (k > 0) {
      if (i + k < n && v[i + k] <= x) i += k;
      k = k / 2;
    }
    if (i == 0) {
      q[j] = (v[0] <= x);
    } else
      q[j] = i + 1;
  }
  for (j = 0; j < m; j++) cout << q[j] << '\n';
  return 0;
}
