#include<bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
set<int> a;
vector<int> c;
for(int i = 0; i < n; i++) {
int x; cin >> x;
a.insert(x);
c.push_back(x);
}
int m; cin >> m;
vector<int> b(m);
for(int i = 0; i < m; i++) {
cin >> b[i];
c.push_back(b[i]);
}
sort(c.rbegin(), c.rend());
multimap<int, int> mp;
vector<bool> ok(n + 1, false);
for(int k = 0; k < c.size(); k++) {
if (a.find(c[k]) != a.end() && !ok[c[k]]) {
ok[c[k]] = true;
} else {
mp.emplace(c[k], k+1);
}
}
for(int i = 0; i < m; i++) {
auto it = mp.find(b[i]);
cout << it->second << ' ';
mp.erase(it);
}
return 0;
}