#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
void solve() {
int n;
cin >> n;
vector<tuple<int, int, int>> participants; // (score, contest_type, index)
for(int i = 0; i < n; i++) {
int x;
cin >> x;
participants.emplace_back(x, 0, 0); // Main contest participants
}
int m;
cin >> m;
vector<int> ans(m);
for(int i = 0; i < m; i++) {
int x;
cin >> x;
participants.emplace_back(x, 1, i); // Replay contest participants
}
sort(participants.begin(), participants.end(), [](const auto& lhs, const auto& rhs) {
int lhs_score = get<0>(lhs);
int lhs_type = get<1>(lhs);
int lhs_index = get<2>(lhs);
int rhs_score = get<0>(rhs);
int rhs_type = get<1>(rhs);
int rhs_index = get<2>(rhs);
if(lhs_score != rhs_score)
return lhs_score > rhs_score; // Higher scores first
if(lhs_type != rhs_type)
return lhs_type < rhs_type; // Main contest before replay contest
if(lhs_type == 1) // Both are replay participants
return lhs_index < rhs_index; // Earlier index first
return false; // Both are main participants with same score, keep their order
});
for(int i = 0; i < participants.size(); i++) {
int score = get<0>(participants[i]);
int contest_type = get<1>(participants[i]);
int index = get<2>(participants[i]);
if(contest_type == 1) {
ans[index] = i + 1; // Positions are 1-based
}
}
for(int i = 0; i < m; i++) {
cout << ans[i];
if(i != m - 1) cout << ' ';
}
// Do not print extra newline as per problem statement
}
int main() {
solve();
return 0;
}