#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr1[4] = {
      0,
  };
  cin >> arr1[0];
  vector<int> arr2(arr1[0], 0);
  for (int i = 0; i < arr1[0]; i++) {
    cin >> arr2[i];
  }
  sort(arr2.begin(), arr2.end());
  arr1[0]--;
  cin >> arr1[1];
  while (cin >> arr1[1]) {
    if (arr1[1] < arr2[0] || arr1[1] >= arr2[arr1[0]]) {
      if (arr1[1] < arr2[0]) {
        cout << 0;
      } else {
        cout << arr1[0] + 1;
      }
    } else {
      arr1[2] = arr1[0] / 2;
      arr1[3] = arr1[2] / 2;
      while (true) {
        if (arr1[1] >= arr2[arr1[2]]) {
          arr1[2] += arr1[3];
        } else {
          arr1[2] -= arr1[3];
        }
        arr1[3] /= 2;
        arr1[3] = max(arr1[3], 1);
        if (arr1[1] < arr2[arr1[2]] && arr1[1] >= arr2[arr1[2] - 1]) {
          cout << arr1[2];
          break;
        }
      }
    }
    cout << endl;
  }
}
