#include <bits/stdc++.h>
using namespace std;

#define ll long long

// -------- Monotonic Stack -----------

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n; cin >> n;
    vector<ll> v(n), res(n, -1);
    stack<ll> st;

    for(auto &x: v) cin >> x;

    for(int i = 0; i < n; i++){
        while (!st.empty() && v[st.top()] < v[i]){
            res[st.top()] = i+1;
            st.pop();
        }
        st.push(i);
    }

    ll q, x; cin >> q;
    while (q--)
    {
        cin >> x;
        cout << res[x-1] << "\n";
    }
    
    
    return 0;
}