/*
ALLAH IS GREAT
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nl "\n"
#define mod 10000007
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mx 2000007
ll arr[mx];
ll tree[mx * 3];
void init(ll node, ll b, ll e)
{
if (b == e) {
tree[node] = b;
return;
}
ll Left = node * 2;
ll Right = node * 2 + 1;
ll mid = (b + e) / 2;
init(Left, b, mid);
init(Right, mid + 1, e);
if (arr[tree[Left]] < arr[tree[Right]]) {
tree[node] = tree[Left];
} else {
tree[node] = tree[Right];
}
}
ll query(ll node, ll b, ll e, ll i, ll j)
{
if (i > e || j < b)
return -1; // out of range, invalid index
if (b >= i && e <= j)
return tree[node]; // Relevant Segment
ll Left = node * 2;
ll Right = node * 2 + 1;
ll mid = (b + e) / 2;
ll p1 = query(Left, b, mid, i, j);
ll p2 = query(Right, mid + 1, e, i, j);
if (p1 == -1) return p2;
if (p2 == -1) return p1;
if (arr[p1] < arr[p2]) {
return p1;
} else {
return p2;
}
}
void update(ll node, ll b, ll e, ll index, ll new_value)
{
if (b == e) {
arr[b] = new_value;
tree[node] = b;
return;
}
ll Left = node * 2;
ll Right = node * 2 + 1;
ll mid = (b + e) / 2;
if (index <= mid) {
update(Left, b, mid, index, new_value);
} else {
update(Right, mid + 1, e, index, new_value);
}
if (arr[tree[Left]] < arr[tree[Right]]) {
tree[node] = tree[Left];
} else {
tree[node] = tree[Right];
}
}
int main()
{
boost;
ll n;
cin >> n;
for (ll i = 1; i <= n; i++) {
cin >> arr[i];
}
init(1, 1, n);
ll q;
cin>>q;
while (q--) {
ll l=1, r=n, new_value;
cin >> new_value;
ll min_pos = query(1, 1, n, l, r);
cout<<min_pos<<nl;
update(1, 1, n, min_pos, new_value);
}
return 0;
}