#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<deque>
using namespace std;
int l=0,sum=0,r,s,n,x,y,m;
char c;
int a[2000003],b[2000004];
deque<int>dq;
int t,h=0;
int main(){
cin>>n>>m>>a[0];
cout<<999<<endl;
for(int i=1;i<n;i++) {
cin>>a[i];//get new int
if(a[b[t]]<a[i]){//maintaining a monotonic doube-ended queue.
b[++t]=i;
}
else{
while(a[b[t]]>=a[i]&&t>=h){
t--;
}
b[++t]=i;
}
if(b[h]-i>=m)
h++;
// for(int j=h;j<=t;j++)
{
cout<<a[b[h]]<<" ";
}
cout<<endl;
}
}
写不动了,数组模拟deque乱七八糟