/*

    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;
map<int, int> mp;

signed main(){
    cin >>n >>m;
    int a[n + 1];
    for (int i = 1; i < m; ++i){
        cin >>a[i];
        ++mp[a[i]];
    }
    for (int i = m; i <= n; ++i){
        cin >>a[i]; ++mp[a[i]];
        cout <<mp.begin() -> first <<' ';
        if (--mp[a[i - m + 1]] == 0) mp.erase(a[i - m + 1]);
    }
    return 0;
}