#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),ed=(b);i<=ed;++i)
#define DREP(i,a,b) for(int i=(a),ed=(b);i>=ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x; 
}

const int N=5e5+10,inf=0x3f3f3f3f;
int n,k,a[N],b[N],ind[N];
vector<int> E[N];
priority_queue<int,vector<int>,greater<int> > q;

namespace SegmentTree{
#define ls(p) p<<1
#define rs(p) p<<1|1
    int tr[N<<2];
    inline void pushup(int p){tr[p]=min(tr[ls(p)],tr[rs(p)]);}
    inline void Build(int p,int l,int r){
        tr[p]=inf;if(l==r)return;
	int mid=(l+r)>>1;
	Build(ls(p),l,mid),Build(rs(p),mid+1,r);
    }
    inline void Insert(int p,int l,int r,int pos,int v){
	if(l==r){tr[p]=v;return;}
	int mid=(l+r)>>1;
	if(mid>=pos)Insert(ls(p),l,mid,pos,v);
	else Insert(rs(p),mid+1,r,pos,v);
	pushup(p);
    }
    inline int Query(int p,int l,int r,int L,int R){
	if(L>R)return inf;
	if(L<=l&&r<=R)return tr[p];
	int mid=(l+r)>>1,ans=inf;
	if(L<=mid)ans=min(ans,Query(ls(p),l,mid,L,R));
	if(mid<R)ans=min(ans,Query(rs(p),mid+1,r,L,R));
	return ans;
    }
}using namespace SegmentTree;

int main(){
    //freopen("in.in","r",stdin);
    n=read(),k=read();REP(i,1,n)a[i]=read(),b[a[i]]=i;
    Build(1,1,n);
    DREP(i,n,1){
	int p=Query(1,1,n,max(1,b[i]-k+1),b[i]-1);
	if(p^inf)E[b[i]].push_back(b[p]),++ind[b[p]];
	p=Query(1,1,n,b[i]+1,min(n,b[i]+k-1));
	if(p^inf)E[b[i]].push_back(b[p]),++ind[b[p]];
	Insert(1,1,n,b[i],i);
    }
    REP(i,1,n)if(!ind[i])q.push(i);
    int cnt=0;
    while(q.size()){
	int u=q.top();q.pop();
	a[u]=++cnt;
	for(int v:E[u])
	    if(!--ind[v])q.push(v);
    }
    REP(i,1,n-1)printf("%d\n",a[i]);
    printf("%d",a[n]);
    return 0;
}
