#include<bits/stdc++.h>
using namespace std;
int n,m,a[114514],top;
void res(int l,int r)
{
top = 0;
for(int i = l; i <= r; i++) if(a[i] <= a[top]) top = i;
}
int main(){
a[0] = 0x3f3f3f3f;
scanf("%d%d",&n,&m);
for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
for(int i = 1; i <= n - m + 1; i++){
if(top < i) res(i,i + m - 1);
else if(a[i+m-1] <= a[top]) top = i + m - 1;
printf("%d\n",a[top]);
}
return 0;
}