#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 10;
const ll MOD = 1e9 + 7;
void solve()
{
ll 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});
}
ll q;
cin >> q;
while(q--) {
ll p;
cin >> p;
auto temp = pq.top();
pq.pop();
cout << temp.second << "\n";
pq.push({p, temp.second});
}
}
int main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
solve();
}