#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<long long> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<>> minHeap;
for (int i = 0; i < n; i++) {
minHeap.push({arr[i], i});
}
int m;
cin >> m;
while (m--) {
long long temp;
cin >> temp;
while (!minHeap.empty() && minHeap.top().second < 0) {
minHeap.pop();
}
if (!minHeap.empty()) {
long long minVal = minHeap.top().first;
int pos = minHeap.top().second;
cout << pos + 1 << endl;
minHeap.pop();
minHeap.push({temp, pos});
}
}
return 0;
}