#include <bits/stdc++.h>
using namespace std;
const int NMAX = 50005;
int n, x;
vector<int> a;
void readData() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    a.push_back(x);
  }
}
int lessOrEqual(int x) {
  int i = upper_bound(a.begin(), a.end(), x) - a.begin();
  if (i > 0 && a[i - 1] <= x) return i;
  return 0;
}
void solve() {
  sort(a.begin(), a.end());
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    printf("%d\n", lessOrEqual(x));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  readData();
  solve();
  return 0;
}
