#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (3.141592653589)
#define mod 1000000007
#define pb push_back
#define vi vector<ll>
#define mp make_pair
#define f first
#define s second
#define sz(container) (ll) container.size()
#define setp(x) cout << fixed << setprecision(x)
#define all(container) container.begin(), container.end()
#define rall(container) container.rbegin(), container.rend()
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int main()
{
fast;
ll n;
cin >> n;
map<ll, ll> m;
set<ll> s;
for (ll i = 0; i < n; i++)
{
ll x;
cin >> x;
m[x] = i + 1;
s.insert(x);
}
ll q;
cin >> q;
while (q--)
{
ll x;
cin >> x;
cout << m[*s.begin()] << "\n";
m[x] = m[*s.begin()];
m.erase(*s.begin());
s.erase(s.begin());
s.insert(x);
}
}