#include <bits/stdc++.h>
#define maxn 1000005
#define endl '\n'

using namespace std;

typedef long long ll;
typedef double db;
typedef pair <int,int> par;
typedef pair <par,int> tri;
const db eps = 1e-9;
const db pi = acos(-1);
const int inf = 1<<30;

int n, k, a[maxn], rmq[maxn][22];

int query ( int a, int b ) {
	int e = 31 - __builtin_clz ( b-a+1 );
	return min ( rmq[a][e], rmq[b-(1<<e)+1][e] );
}

int main() {
    //~ #ifdef acm
        //~ freopen ("a.in", "r", stdin );
        //~ freopen ("slingshot.out", "w", stdout );
    //~ #endif // acm
	//~ ios_base::sync_with_stdio (0);
	//~ cin.tie(0);
	
	cin >> n >> k;
	for ( int i = 1; i <= n; i ++ ) {
		cin >> a[i];
		rmq[i][0] = a[i];
	}

	for ( int j = 1; (1<<j) <= n; j ++ )
		for ( int i = 1; i+(1<<j)-1 <= n; i ++ )
			rmq[i][j] = min ( rmq[i][j-1], rmq[i+(1<<(j-1))][j-1] );
	for ( int i = 1; i+k-1 <= n; i ++ ) 
		cout << query ( i, i+k-1 ) << " \n"[i+k-1==n];

	return 0;
}


