#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sp " "
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
void messi()
{
ll n;
cin >> n;
ll a[n];
set<pair<ll, ll>> v;
for (ll i = 0; i < n; i++)
{
cin >> a[i];
v.insert({a[i], i});
}
ll q;
cin >> q;
while (q--)
{
ll x;
cin >> x;
auto in = *v.begin();
cout << in.second + 1 << endl;
v.erase(in);
a[in.second] = x;
v.insert({x, in.second});
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
ll tc = 1; // cin>>tc;
while (tc--)
{
messi();
}
return 0;
}