#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n),b(n);
map<int,int> aa;
for(int i=0;i<n;i++){
cin >> a[i];
aa[a[i]]=i+1;
}
b = a;
sort(b.begin(),b.end());
int q;
vector<int> c;
cin >> q;
int minn = b[0];
int l = 0;
for(int i=0;i<q;i++){
int tt;
cin >> tt;
if(tt<=minn){
c.push_back(aa[b[l]]);
aa[tt]=aa[b[l]];
minn = tt;
}else{
l++;
c.push_back(aa[minn]);
aa[tt]=aa[b[l]];
minn=b[l];
}
}
for(int i=0;i<c.size();i++){
cout << c[i]<<"\n";
}
}