#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,l;
  cin>>n>>l;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  deque<int> q;
  auto pb=[&](int x){
    while(!q.empty()&&a[q.back()]>=a[x]) q.pop_back();
    q.push_back(x);
  };
  for(int i=0;i<l;i++) pb(i);
  for(int i=l;i<n;i++){
    cout<<a[q.front()]<<" ";
    pb(i);
    while(!q.empty()&&q.front()<=i-l) q.pop_front();
  }
  cout<<a[q.front()]<<endl;
  return 0;
}