#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N, L, a[1000010];
deque<int> deq;

int main() {
    cin >> N >> L;
    rep(i, N) cin >> a[i];

    // init
    int i;
    for (i = 0; i < L; i++) {
        while (!deq.empty() && a[i] <= a[deq.back()]) {
            deq.pop_back();
        }
        deq.push_back(i);
    }

    for (; i < N; i++) {
        cout << a[deq.front()] << " ";
        while (!deq.empty() && deq.front() <= i-L) {
            deq.pop_front();
        }
        while (!deq.empty() && a[i] <= a[deq.back()]) {
            deq.pop_back();
        }
        deq.push_back(i);
    }
    cout << a[deq.front()] << endl;
}

