// Slower C++ solution:
//2018.9.21 by ljz

#include<bits/stdc++.h>

using namespace std;

#define res register int

#define LL long long

#define inf 0x3f3f3f3f

#define eps 1e-15

inline int read(){

    res s=0;

    bool w=0;

    char ch=getchar();

    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}

    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();

    return w?-s:s;

}

inline void _swap(res &x,res &y){

    x^=y^=x^=y;

}

inline int _abs(const res &x){

    return x>0?x:-x;

}

inline int _max(const res &x,const res &y){

    return x>y?x:y;

}

inline int _min(const res &x,const res &y){

    return x<y?x:y;

}

const int N=1e6+10;

namespace MAIN{

    int a[N],n,k;

    namespace Segtree{

        int mn[N<<2];

        inline void pushup(const res &rt){

            mn[rt]=_min(mn[rt<<1],mn[rt<<1|1]);

        }

        void build(const res &rt,const res &l,const res &r){

            mn[rt]=inf;

            if(l==r)return;

            res mid=(l+r)>>1;

            build(rt<<1,l,mid),build(rt<<1|1,mid+1,r);

        }

        void update(const res &rt,const res &l,const res &r,const res &p,const res &va){

            if(l==r){mn[rt]=va;return;}

            res mid=(l+r)>>1;

            if(p<=mid)update(rt<<1,l,mid,p,va);

            else update(rt<<1|1,mid+1,r,p,va);

            pushup(rt);

        }

        int query(const res &rt,const res &l,const res &r,const res &L,const res &R){

            if(L>R)return 0;

            if(L<=l&&r<=R)return mn[rt];

            res mid=(l+r)>>1,ans=inf;

            if(L<=mid)ans=_min(ans,query(rt<<1,l,mid,L,R));

            if(R>mid)ans=_min(ans,query(rt<<1|1,mid+1,r,L,R));

            return ans;

        }

    }

    struct E{

        int next,to;

        E() {}

        E(res next,res to):next(next),to(to) {}

    }edge[N];

    int head[N],cnt,du[N];

    inline void addedge(const res &u,const res &v){

        edge[++cnt]=E(head[u],v),head[u]=cnt,du[v]++;

    }

    int x;

    priority_queue<int,vector<int>,greater<int> >Q;

    int id[N],idx;

    inline void topsort(){

        for(res i=1;i<=n;i++)if(!du[i])Q.push(i);

        while(!Q.empty()){

            res u=Q.top();

            Q.pop();

            id[u]=++idx;

            for(res i=head[u];~i;i=edge[i].next){

                res tox=edge[i].to;

                if(--du[tox]==0)Q.push(tox);

            }

        }

    }

    inline void MAIN(){

        memset(head,-1,sizeof(head));

        n=read(),k=read();

        for(res i=1;i<=n;i++)a[read()]=i;

        Segtree::build(1,1,n);

        for(res i=n;i;i--){

            x=Segtree::query(1,1,n,a[i]+1,_min(a[i]+k-1,n));

            if(x>=1&&x<=n)addedge(a[i],a[x]);

            x=Segtree::query(1,1,n,_max(1,a[i]-k+1),a[i]-1);

            if(x>=1&&x<=n)addedge(a[i],a[x]);

            Segtree::update(1,1,n,a[i],i);

        }

        topsort();

        for(res i=1;i<=n;i++)printf("%d\n",id[i]);

    }

}

int main(){

    MAIN::MAIN();

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.089565146328226x):
#include<bits/stdc++.h>

#define LL long long



using namespace std;

const int N=5e5+10,M=1e8+10;

int rd()

{

    int x=0,w=1;char ch=0;

    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}

    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}

    return x*w;

}

int to[N<<1],nt[N<<1],dg[N],hd[N],tot=1;

void adde(int x,int y){++tot,to[tot]=y,nt[tot]=hd[x],hd[x]=tot,++dg[y];}

int n,m,a[N],an[N];

int mi[N<<2];

void psup(int o){mi[o]=min(mi[o<<1],mi[o<<1|1]);}

void modif(int o,int l,int r,int lx,int x)

{

    if(l==r){mi[o]=x;return;}

    int mid=(l+r)>>1;

    if(lx<=mid) modif(o<<1,l,mid,lx,x);

    else modif(o<<1|1,mid+1,r,lx,x);

    psup(o);

}

int quer(int o,int l,int r,int ll,int rr)

{

    if(ll>rr) return n+1;

    if(ll<=l&&r<=rr) return mi[o];

    int an=n+1,mid=(l+r)>>1;

    if(ll<=mid) an=min(an,quer(o<<1,l,mid,ll,rr));

    if(rr>mid) an=min(an,quer(o<<1|1,mid+1,r,ll,rr));

    psup(o);

    return an;

}

void bui(int o,int l,int r)

{

    if(l==r){mi[o]=n+1;return;}

    int mid=(l+r)>>1;

    bui(o<<1,l,mid),bui(o<<1|1,mid+1,r);

    psup(o);

}

struct node

{

    int x;

    bool operator < (const node &bb) const {return a[x]>a[bb.x];}

};

priority_queue<node> q;



int main()

{

////

    n=rd(),m=rd();

    for(int i=1;i<=n;++i) a[rd()]=i;

    bui(1,1,n);

    for(int i=n;i;--i)

    {

	int n1=quer(1,1,n,max(a[i]-m+1,1),a[i]-1),n2=quer(1,1,n,a[i]+1,min(a[i]+m-1,n));

	if(n1<=n) adde(i,n1);

	if(n2<=n) adde(i,n2);

	modif(1,1,n,a[i],i);

    }

    for(int i=1;i<=n;++i)

	if(!dg[i]) q.push((node){i});

    for(int h=1;h<=n;++h)

    {

	int x=q.top().x;

	q.pop();

	an[a[x]]=h;

	for(int i=hd[x];i;i=nt[i])

	{

	    int y=to[i];

	    --dg[y];

	    if(!dg[y]) q.push((node){y});

	}

    }

    for(int i=1;i<=n;++i) printf("%d\n",an[i]);

    return 0;

}