#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int t;
cin >> t;
vector<int> arr;
while (t--)
{
int n;
cin >> n;
arr.push_back(n);
}
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> mh;
for (int i = 0; i < arr.size(); i++)
{
mh.push(make_pair(arr[i], i));
}
int q;
cin >> q;
while (q--)
{
int x;
cin >> x;
pair<int, int> minPair = mh.top();
int minI = minPair.second;
cout << minI + 1 << endl;
arr[minI] = x;
mh.pop();
mh.push(make_pair(x, minI));
}
return 0;
}