#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using LL = long long;
int main() {
cin.tie (nullptr) -> ios_base :: sync_with_stdio (false);
int tests = 1;
// cin >> tests;
while (tests--) {
int n;
cin >> n;
priority_queue < pair <int, int>, vector < pair <int, int> >, greater < pair <int, int> > > pq;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
pq.push ({x, i});
}
int q;
cin >> q;
while (q--) {
int x;
cin >> x;
auto u = pq.top ();
pq.pop ();
cout << u.second << '\n';
u.first = x;
pq.push (u);
}
while (!pq.empty ()) pq.pop ();
}
return 0;
}