#include <bits/stdc++.h>

// Defination {{{
#define PI pair<int, int>
#define mk make_pair
#define reg register
#define ll long long
#define rep(i, a, b) for(reg int i = a; i <= b; ++i)
#define per(i, a, b) for(reg int i = a; i >= b; --i)
#define pb push_back
// }}}

using namespace std;

int min(reg int a, reg int b) { return a < b ? a : b; }
int max(reg int a, reg int b) { return a > b ? a : b; }

template<typename T> void read(T &x) {
    x = 0; reg char ch = getchar(); reg int f = 1;
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    x *= f;
}

#define N 500005

int n, k, cnt;
int a[N], b[N], l[N], r[N];

class Segment_Tree {
public:
    int tree[N << 2];

    void pushup(int x) { tree[x] = min(tree[x << 1], tree[x << 1 | 1]); }

    void build(int l, int r, int x) {
        if (l == r) {
            tree[x] = n + 1;
            return;
        }
        reg int mid = l + r >> 1;
        build(l, mid, x << 1);
        build(mid + 1, r, x << 1 | 1);
        pushup(x);
    }

    void modify(int l, int r, int pos, int val, int x) {
        if (l == r) {
            tree[x] = val;
            return;
        }
        int mid = l + r >> 1;
        if (pos <= mid) modify(l, mid, pos, val, x << 1);
        else modify(mid + 1, r, pos, val, x << 1 | 1);
        pushup(x);
    }

    int query(int l, int r, int la, int ra, int x) {
        if (l >= la && r <= ra) return tree[x];
        int mid = l + r >> 1;
        int res = n + 1;
        if (la <= mid) res = min(res, query(l, mid, la, ra, x << 1));
        if (ra > mid) res = min(res, query(mid + 1, r, la, ra, x << 1 | 1));
        return res;
    }

} seg;

int fir[N], nx[N << 2], to[N << 2], in[N];

inline void add(int _, int __) {
    nx[++cnt] = fir[_];
    fir[_] = cnt;
    to[cnt] = __;
}

inline void topo() {
    priority_queue<int, vector<int>, greater<int> > q;
    rep (i, 1, n) if (in[i] == 0) q.push(i);
    int res = 0;
    while (!q.empty()) {
        int x = q.top();
        a[x] = ++res;
        q.pop();
        for (int i = fir[x]; i; i = nx[i]) {
            int v = to[i];
            --in[v];
            if (in[v] == 0) q.push(v);
        }
    }
    rep (i, 1, n) printf("%d\n", a[i]);
}

int main() {
    read(n), read(k);
    rep (i, 1, n) read(a[i]), b[a[i]] = i;
    if (k <= 1) {
        sort(a + 1, a + n + 1);
        rep (i, 1, n) printf("%d\n", a[i]);
        return 0;
    }
    seg.build(1, n, 1);
    per (i, n, 1) {
        int x = seg.query(1, n, min(n, b[i] + 1), min(n, b[i] + k - 1), 1);
        if (x != n + 1) add(b[i], b[x]), in[b[x]]++;
        x = seg.query(1, n, max(1, b[i] - k + 1), max(1, b[i] - 1), 1);
        if (x != n + 1) add(b[i], b[x]), in[b[x]]++;
        seg.modify(1, n, b[i], i, 1);
    }
    topo();
    return 0; 
}


/*
 _____  ____    _____
|__  / |  _ \  |__  /
  / /  | |_) |   / / 
 / /_  |  _ <   / /_ 
/____| |_| \_\ /____|
  
 _______________________________________ 
/ permutation.cpp is created by zrz who \
\ is weak                               /
 --------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
*/


Measured memory_bytes: 28920