#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define lsb(x) (x & (-x))
#define vi vector<int>
#define YES { cout << "YES" << endl; return; }
#define NO { cout << "NO" << endl; return; }
using ll = long long;
using pii = std::pair<int, int>;
using namespace std;
void solve_testcase() {
int n, q;
cin >> n;
multiset<pii>s;
for (int i = 1, x; i <= n; ++i) {
cin >> x;
s.insert({x, i});
}
cin >> q;
auto query = [&](int x) {
auto p = *s.begin();
s.erase(p);
s.insert({x, p.se});
cout << p.se << "\n";
};
for (int i = 1, x; i <= q; ++i) {
cin >> x;
query(x);
}
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t = 1;
// cin >> t;
while (t--)
solve_testcase();
return 0;
}