#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 2000002
int V[MAX];
int test,k;
void build()
{
for (int i = test - 1; i > 0; --i)
V[i] = max(V[i<<1] , V[i<<1|1]);
}
void query(int l , int r)
{
int ans = 0;
for(l+=test, r+=test; l < r; l>>=1, r>>=1) {
if(l%2) ans = max( ans, V[l++] );
if(r%2) ans = max( ans, V[--r] );
}
cout << ans << " ";
}
int main()
{
scanf("%d", &test);
for(int i =0; i < test ; ++i)
{
scanf("%d", &V[test+i]);
}
scanf("%d", &k);
build();
for (int i = 0, j ; i <= test-k; i++)
{
j = i+k-1 ;
query(i,j);
}
cout << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBNQVggMjAwMDAwMgppbnQgVltNQVhdOwppbnQgdGVzdCxrOwoKdm9pZCBidWlsZCgpIAp7ICAKCWZvciAoaW50IGkgPSB0ZXN0IC0gMTsgaSA+IDA7IC0taSkgCgkJVltpXSA9IG1heChWW2k8PDFdICwgVltpPDwxfDFdKTsKfQoKdm9pZCBxdWVyeShpbnQgbCAsIGludCByKQp7CglpbnQgYW5zID0gMDsKICAgIGZvcihsKz10ZXN0LCByKz10ZXN0OyBsIDwgcjsgbD4+PTEsIHI+Pj0xKSB7CiAgICAgICAgaWYobCUyKSBhbnMgPSBtYXgoIGFucywgVltsKytdICk7CiAgICAgICAgaWYociUyKSBhbnMgPSBtYXgoIGFucywgVlstLXJdICk7CiAgICB9Cgljb3V0IDw8IGFucyA8PCAiICI7Cn0KCmludCBtYWluKCkKewoJc2NhbmYoIiVkIiwgJnRlc3QpOwoKCWZvcihpbnQgaSA9MDsgaSA8IHRlc3QgOyArK2kpCgl7CgkJc2NhbmYoIiVkIiwgJlZbdGVzdCtpXSk7Cgl9CgoJc2NhbmYoIiVkIiwgJmspOwoKCWJ1aWxkKCk7CgoJZm9yIChpbnQgaSA9IDAsIGogOyBpIDw9IHRlc3QtazsgaSsrKQoJewoJCWogPSBpK2stMSA7CgkJcXVlcnkoaSxqKTsKCX0KCWNvdXQgPDwgZW5kbDsKCglyZXR1cm4gMDsKfQ==
prog.cpp:27:2: error: use of undeclared identifier 'scanf'
scanf("%d", &test);
^
prog.cpp:31:3: error: use of undeclared identifier 'scanf'
scanf("%d", &V[test+i]);
^
prog.cpp:34:2: error: use of undeclared identifier 'scanf'
scanf("%d", &k);
^
3 errors generated.