#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
int N, Q;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
cin >> Q;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> minHeap;
for (int i = 0; i < N; i++) {
minHeap.push({A[i], i});
}
for (int i = 0; i < Q; i++) {
int X;
cin >> X;
pair<int, int> minPair = minHeap.top();
minHeap.pop();
cout << minPair.second + 1 << endl;
A[minPair.second] = X;
minHeap.push({X, minPair.second});
}
return 0;
}