#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1ll << 30ll)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, L, a[1000100];
RPQ que;

signed main(){
    cin >> N >> L;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        que.push(mk(a[i], i));
        if(i < L - 1){
            continue;
        }
        while(!que.empty()){
            if(que.top().second <= i - L){
                que.pop();
            }
            else {
                break;
            }
        }
        cout << que.top().first;
        if(i < N - 1)cout << " ";
    }
    cout << endl;

    return 0;
}

/*


*/
