// Slower C++ solution:
#include<set>

#include<map>

#include<cmath>

#include<queue>

#include<bitset>

#include<string>

#include<cstdio>

#include<cctype>

#include<cstdlib>

#include<cstring>

#include<cassert>

#include<sstream>

#include<numeric>

#include<iostream>

#include<algorithm>

#include<functional>



#define For(i,x,y) for (int i=x;i<y;i++)

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define Lsn (x<<1)

#define Rsn (x<<1|1)

#define Mid ((L+R)>>1)



#define dprintf(...) fprintf(stderr,__VA_ARGS__)

using namespace std;



typedef long long ll;

typedef double db;

typedef vector<int> Vi;

typedef pair<int,int> pii;



int IN(){

	int c,f,x;

	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');

	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;

}

void Output(int x){

	if (x>=10) Output(x/10);

	putchar(x%10+'0');

}



const int N=500000+19;

const int oo=(1<<30)-1;



priority_queue<int> Q;

int A[N],d[N],C[N],res[N];

int n,k;



int Query(int x){

	int res=0;

	for (;x;x-=x&-x) res+=C[x];

	return res;

}

void Add(int x){

	for (;x<=n;x+=x&-x) C[x]++;

}



pii mn[N*4];

int plu[N*4];

int Ql,Qr;



void Build(int x,int L,int R){

	if (L==R){

		mn[x]=mp(d[L],-L);

		return;

	}

	Build(Lsn,L,Mid);

	Build(Rsn,Mid+1,R);

	mn[x]=min(mn[Lsn],mn[Rsn]);

}

void Plus(int x,int v){

	plu[x]+=v;

	mn[x].fi+=v;

}

void Down(int x){

	if (plu[x]){

		Plus(Lsn,plu[x]);

		Plus(Rsn,plu[x]);

		plu[x]=0;

	}

}

void Modify(int x,int L,int R){

	if (Ql<=L&&R<=Qr){

		Plus(x,-1);

		return;

	}

	Down(x);

	if (Ql<=Mid) Modify(Lsn,L,Mid);

	if (Qr>Mid) Modify(Rsn,Mid+1,R);

	mn[x]=min(mn[Lsn],mn[Rsn]);

}

void Change(int x,int L,int R){

	if (L==R){

		mn[x]=mp(oo,-L);

		return;

	}

	Down(x);

	Ql<=Mid?Change(Lsn,L,Mid):Change(Rsn,Mid+1,R);

	mn[x]=min(mn[Lsn],mn[Rsn]);

}



int main(){

	n=IN(),k=IN()-1;

	For(i,1,n+1) A[IN()]=i;

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

		d[A[i]]=Query(min(A[i]+k,n))-Query(max(A[i]-k,1)-1);

		Add(A[i]);

	}

	For(i,1,n+1){

		if (!d[i]) Q.push(i),d[i]=oo;

	}

	Build(1,1,n);

	For(t,1,n+1){

		int x=Q.top();Q.pop();

		res[x]=n-t+1;

		Ql=max(x-k,1);

		Qr=min(x+k,n);

		Modify(1,1,n);

		while (mn[1].fi==0){

			Q.push(-mn[1].se);

			Ql=-mn[1].se;

			Change(1,1,n);

		}

	}

	For(i,1,n+1){

		Output(res[i]);

		puts("");

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.355680303685863x):
#include<cstdio>

#include<algorithm>

using namespace std;

int heap[500005],top;

struct tree{

	int max;

}t[2000005];

struct link{

	int next,to;

}l[500005];

int n,sum,cnt,k;

int a[500005],p[500005],pre[500005],ans[500005],tmp[500005],head[500005];

inline int read(){

	int ret=0;char c=getchar();

	while((c<'0')||(c>'9'))c=getchar();

	while((c>='0')&&(c<='9'))ret=(ret<<1)+(ret<<3)+c-'0',c=getchar();

	return ret;

}

int P[20],pcnt;

void print(int x){

	if(x==0){puts("0");return;}

	while(x)P[++pcnt]=x%10,x/=10;

	while(pcnt)putchar(P[pcnt--]+'0');

	putchar('\n');

}

#define mid ((l+r)>>1)

#define lson index<<1

#define rson index<<1|1

inline int query(int L,int R,int l,int r,int index){

	if((L<=l)&&(R>=r))return t[index].max;

	if(R<=mid)return query(L,R,l,mid,lson);

	if(L>mid)return query(L,R,mid+1,r,rson);

	return max(query(L,R,l,mid,lson),query(L,R,mid+1,r,rson));

}

void updata(int l,int r,int index,int k,int x){

	t[index].max=x;

	if(l==r)return;

	if(k<=mid)updata(l,mid,lson,k,x);

	else updata(mid+1,r,rson,k,x);

}

void add(int u,int v){l[++cnt]=(link){head[u],v};head[u]=cnt;}

void ins(int x){

	heap[++top]=x;int k=top;

	while(k>1){

		if(heap[k>>1]>heap[k])swap(heap[k],heap[k>>1]);

		else break;

		k>>=1;

	}

}

void pop(){

	heap[1]=heap[top];int k=1;top--;

	while((k<<1)<=top){

		int v=k<<1;

		if(v<top)if(heap[v|1]<heap[v])v|=1;

		if(heap[v]<heap[k])swap(heap[k],heap[v]);

		else break;

		k=v;

	}

}

int main(){

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

	for(int i=1;i<=n;i++)p[i]=read(),a[p[i]]=i;

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

		int r=min(n,a[i]+k-1);

		pre[i]=a[query(a[i],r,1,n,1)];

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

	}

	for(int i=1;i<=n;i++)if(pre[i])add(pre[i],a[i]);

	for(int i=1;i<=n;i++)if(pre[i]==0)ins(a[i]);

	cnt=0;

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

		int u=heap[1];ans[u]=++cnt;pop();

		for(int j=head[u];j;j=l[j].next)ins(l[j].to);

	}

	for(int i=1;i<=n;i++)print(ans[i]);

}