#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  std::vector<int> v(n);
  std::vector<int> ps(1000000, 0);
  for (int(i) = 0; (i) < (n); (i)++) cin >> v[i], ps[v[i]]++;
  ;
  int q;
  cin >> q;
  for (int(i) = (1); (i) < (1000000); (i)++) {
    ps[i] += ps[i - 1];
  }
  for (int(i) = 0; (i) < (q); (i)++) {
    int x;
    cin >> x;
    if (x > 100000)
      cout << ps[100000] << endl;
    else
      cout << ps[x] << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
