#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve() {
ll n; cin >> n;
map<ll, ll> value_to_pos;
for (ll i = 1; i <= n; ++i) {
ll value; cin >> value;
value_to_pos[value] = i;
}
ll q; cin >> q;
while (q--) {
ll x; cin >> x;
auto min_it = value_to_pos.begin();
ll min_value = min_it->first;
ll min_pos = min_it->second;
cout << min_pos << endl;
value_to_pos.erase(min_it);
value_to_pos[x] = min_pos;
}
}
int main() {
fast
ll t = 1;
while (t--) {
solve();
}
return 0;
}