// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>



using namespace std ;



#define inf 99999999

#define N 1000007

#define ls x<<1

#define rs x<<1|1



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



int tot , n , m , cnt , k ;

int nex[2*N] , fire[N] , to[2*N] ;

int To[N] , Mn[4*N] , in[N] , Ans[N] ;



inline int read()

{

    int x = 0 , f = 1 ; char c = getchar();

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

    while( c >= '0' && c <= '9' ) x = x * 10 + c - 48 , c = getchar() ;

    return x * f ;

}



void add(int u , int v){

    nex[++tot] = fire[u] ;

    fire[u] = tot ;

    to[tot] = v ;

    in[v]++ ;

    return ;

}



void build(int x , int l , int r){

    Mn[x] = inf ;

    if( l == r ) return ;

    int mid = l + r >> 1 ;

    build( ls , l , mid ) ; build( rs , mid + 1 , r ) ;

}



void update(int x , int l , int r , int pos , int t ){

    Mn[x] = min( Mn[x] , t ) ;

    if( l == r ) return ;

    int mid = l + r >> 1 ;

    if( pos <= mid ) update( ls , l , mid , pos , t ) ;

    else update( rs , mid + 1 , r , pos , t ) ;

}



int Ask(int x , int l , int r , int ll , int rr){

    if( ll > rr ) return inf ;

    if( l > rr || r < ll ) return inf ;

    if( ll <= l && r <= rr ) return Mn[x] ;

    int mid = l + r >> 1 ;

    return min( Ask( ls , l , mid , ll , rr ) , Ask( rs , mid + 1 , r , ll , rr ) ) ;

}



void topo(){

    for(int i = 1 ; i <= n ; i++ ) if( !in[i] ) q.push( i ) ;

    while( !q.empty() ){

        int u = q.top() ; q.pop() ;

        Ans[u] = ++cnt ;

        for(int i = fire[u] ; i ; i = nex[i] ){

            int v = to[i] ;

            in[v]-- ;

            if( !in[v] ) q.push( v ) ;

        }

    }

    return ;

}



int main()

{

    scanf("%d%d" , &n , &k ) ;

    for(int i = 1 ; i <= n ; i++ ) To[read()] = i ;

    build( 1 , 1 , n ) ;

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

        int now = Ask( 1 , 1 , n , To[i] + 1 , min( To[i] + k - 1 , n ) ) ;

        if( now != inf ) add( To[i] , To[now] ) ;

        now = Ask( 1 , 1 , n , max( 1 , To[i] - k + 1 ) , To[i] - 1 ) ;

        if( now != inf ) add( To[i] , To[now] ) ;

        update( 1 , 1 , n , To[i] , i ) ;

    }

    topo() ;

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

    return 0 ;

}

// Fastest known solution for this problem: