#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

int main(){
	ll N,L;
	cin >> N >> L;
	ll a[N];
	FOR(i,0,N)cin >> a[i];
	
	priority_queue<P> pq;
	FOR(i,0,L-1){
		pq.push({-a[i],i});
	}

	FOR(i,L-1,N){
		pq.push({-a[i],i});
		while(pq.top().second<i-L+1){
			pq.pop();
		}
		cout << (i==(L-1)?"":" ") << -pq.top().first;
	}
	cout << endl;
}
