#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define all(v) (v).begin(), (v).end()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define F first
#define S second
const ll M = 1e18 + 7;
const int N = 1e5 + 7;
const int MOD = 1e9 + 7;
void Hrid_solve(){
int n;
cin >> n;
vector<ll> v(n);
priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> pq;
for(ll i = 0; i < n; i++) {
cin >> v[i];
pq.push({v[i],-(i+1)});
}
int q;
cin >> q;
while(q--) {
ll x;
cin >> x;
auto p = pq.top();
ll val = p.first;
ll ind = p.second*(-1);
pq.pop();
pq.push({x,ind*-1});
cout << ind << endl;
}
}
/* ************** What defines us is how well we rise after we Fall !! ************** */
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int tc = 1;
// cin >> tc;
for(int kase = 1; kase <= tc; kase++){
// cout << "Case " << kase << ": ";
Hrid_solve();
}
return 0;
}