#include <iostream>
using namespace std;
const int N_MAX_SIZE = 500000;
const int M_MAX_SIZE = 100000;
int main() {
int n, m, v[N_MAX_SIZE + 1];
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> n;
}
cin >> m;
int x = -1;
for (int i = 1; i <= m; ++i) {
if (x < v[i]) {
x = v[i];
}
cout << x << " ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE5fTUFYX1NJWkUgPSA1MDAwMDA7CmNvbnN0IGludCBNX01BWF9TSVpFID0gMTAwMDAwOwoKaW50IG1haW4oKSB7CglpbnQgbiwgbSwgdltOX01BWF9TSVpFICsgMV07CgljaW4gPj4gbjsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewoJCWNpbiA+PiBuOwoJfQoJY2luID4+IG07CglpbnQgeCA9IC0xOwoJZm9yIChpbnQgaSA9IDE7IGkgPD0gbTsgKytpKSB7CgkJaWYgKHggPCB2W2ldKSB7CgkJCXggPSB2W2ldOwoJCX0KCQljb3V0IDw8IHggPDwgIiAiOwoJfQoJcmV0dXJuIDA7Cn0=