/*

    F U Z U M I  T A K A H A S H I -w-

*/
#include <bits/stdc++.h>

using namespace std;

int n, m;
deque<int> q;

signed main(){
    cin >>n >>m;
    int a[n + 1];
    for (int i = 1; i <= n; ++i){
        cin >>a[i];
        while (!q.empty() && a[i] <= a[q.back()]) q.pop_back();
        q.push_back(i);
        if (q.front() + m <= i) q.pop_front();
        if (i >= m) cout <<a[q.front()] <<' ';
    }
    return 0;
}