#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n, q;
cin >> n;
vector<int> vl(n);
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
for (int i = 0; i < n; ++i) {
cin >> vl[i];
pq.push({vl[i], i});
}
cin >> q;
while (q--) {
int x;
cin >> x;
while (!pq.empty() && pq.top().first != vl[pq.top().second]) {
pq.pop();
}
int min_idx = pq.top().second;
cout << (min_idx + 1) << endl;
vl[min_idx] = x;
pq.push({x, min_idx});
}
return 0;
}