#include <cstdio>
int N, K, l, r, x, c, a[1000009], v[1000009], p[1000009]; char s[19];
int main() {
	scanf("%d %d\n", &N, &K);
	for (int i = 0; i < N; i++) {
		char ch = getchar();
		while (48 <= ch && ch <= 57) a[i] = a[i] * 10 + ch - 48, ch = getchar();
	}
	for (int i = 0; i < K; i++) {
		while (l != r && v[r - 1] >= a[i]) r--;
		v[r] = a[i], p[r++] = i;
	}
	for (int i = K; i <= N; i++) {
		x = v[l]; c = 0;
		while (x > 0) s[c++] = x % 10 + 48, x /= 10;
		while (c--) putchar(s[c]);
		putchar(i == N ? '\n' : ' ');
		if (p[l] == i - K) l++;
		while (l != r && v[r - 1] >= a[i]) r--;
		v[r] = a[i], p[r++] = i;
	}
	return 0;
}
