#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define f first
#define s second

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> drvo; ///find_by_order()  order_of_key()

int n,k;
vector<int> niz;
struct segTree{
    vector<pair<int,int> > minn;
    void build(int l,int r,int i)
    {
        if(l==r)
        {
            minn[i]={niz[l],l};
            return;
        }
        int m=(l+r)>>1;
        build(l,m,2*i);
        build(m+1,r,2*i+1);
        minn[i]=min(minn[2*i],minn[2*i+1]);
    }
    void init()
    {
        minn.resize(4*n);
        build(0,n-1,1);
    }
    pair<int,int> get(int qs,int qe,int l=0,int r=n-1,int i=1)
    {
        if(qs>r||qe<l)
            return {INT_MAX,INT_MAX};
        if(qs<=l&&qe>=r)
            return minn[i];
        int m=(l+r)>>1;
        return min(get(qs,qe,l,m,2*i),get(qs,qe,m+1,r,2*i+1));
    }
}st;
int main()
{
    scanf("%i %i",&n,&k);
    niz.resize(n);
    for(int i=0;i<n;i++)
        scanf("%i",&niz[i]);
    st.init();
    int tr=0;
    while(tr<n)
    {
        pair<int,int> a=st.get(tr,tr+k);
        printf("%i ",a.f);
        int d=a.s-tr;
        k-=d;
        tr=a.s;
        tr++;
    }
    return 0;
}
/*
4 1
4 8 6 3
*/