#include <bits/stdc++.h>
using namespace std;
#define file(name) if (fopen(name".INP", "r")){freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout);}
const int maxn = 1e6 + 7;
int n, k, st[int(log2(maxn)) + 1][maxn];
int get(int l, int r){
int LOG = log2(r - l + 1);
return min(st[LOG][l], st[LOG][r - (1 << LOG) + 1]);
}
void solution(){
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> st[0][i];
for (int i = 1; (1 << i) <= n; i++)
for (int j = 1; j <= n - (1 << i) + 1; j++)
st[i][j] = min(st[i-1][j], st[i-1][j + (1 << (i - 1))]);
for (int i = 1; i <= n - k + 1; i++){
int l = i, r = i + k - 1;
cout << get(l, r) << "\n";
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
file("TEST");
int test = 1;
while (test --> 0) solution();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGZpbGUobmFtZSkgaWYgKGZvcGVuKG5hbWUiLklOUCIsICJyIikpe2ZyZW9wZW4obmFtZSIuSU5QIiwgInIiLCBzdGRpbik7IGZyZW9wZW4obmFtZSIuT1VUIiwgInciLCBzdGRvdXQpO30KCmNvbnN0IGludCBtYXhuID0gMWU2ICsgNzsKCmludCBuLCBrLCBzdFtpbnQobG9nMihtYXhuKSkgKyAxXVttYXhuXTsgCgppbnQgZ2V0KGludCBsLCBpbnQgcil7CglpbnQgTE9HID0gbG9nMihyIC0gbCArIDEpOwoJcmV0dXJuIG1pbihzdFtMT0ddW2xdLCBzdFtMT0ddW3IgLSAoMSA8PCBMT0cpICsgMV0pOwp9Cgp2b2lkIHNvbHV0aW9uKCl7CgoJY2luID4+IG4gPj4gazsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgY2luID4+IHN0WzBdW2ldOwoJZm9yIChpbnQgaSA9IDE7ICgxIDw8IGkpIDw9IG47IGkrKykKCQlmb3IgKGludC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