#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int a[N],n,m;
deque<int> deq;
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=m;i++){
while(!deq.empty()&&a[deq.back()]>=a[i]) deq.pop_back();
deq.push_back(i);
}
printf("%d ",a[deq.front()]);
for(int i=m+1;i<=n;i++){
if(i-deq.front()==m) deq.pop_front();
while(!deq.empty()&&a[deq.back()]>=a[i]) deq.pop_back();
deq.push_back(i);
printf("%d ",a[deq.front()]);
}
return 0;
}