#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 2e6 + 10, maxm = 20;
int n, m, left, right, len, lg, st[maxn][maxm];
int main() {
scanf("%d %d", &n, &m);
memset(st, 127, sizeof(st));
for (int i = 1; i <= n; i++) scanf("%d", st[i]);
for (int j = 1; (1 << j) <= n; j++) {
for (int i = 1; i <= n - (1 << j) + 1; i++) {
st[i][j] = min(st[i][j - 1], st[i + (1 << j - 1)][j - 1]);
}
}
for (int i = 1; i <= n; i++) {
left = max(i - m, 1);
right = i - 1;
len = right - left + 1;
lg = log2(len);
if (right <= 0) {
puts("0");
continue;
}
printf("%d\n", min(st[left][lg], st[right - (1 << lg) + 1][lg]));
}
return 0;
}