#ifdef DEBUG
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <cassert>
#include <sstream>
#include <fstream>
#include <functional>
#include <set>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#else
#include <bits/stdc++.h>
#endif

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#define rep(i, n) for (int i = 0, i##_end_ = (n); i < i##_end_; ++i)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define forn(i, l, r) for (int i = (l), i##_end_ = (r); i <= i##_end_; ++i)
#define nrof(i, r, l) for (int i = (r), i##_end_ = (l); i >= i##_end_; --i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef vector<int> vi;

typedef pair<int, int> pii;

typedef long long LL;

template<typename T> inline bool chkmax(T &x, const T &y) {
	return x < y ? x = y, 1 : 0;
}

template<typename T> inline bool chkmin(T &x, const T &y) {
	return x > y ? x = y, 1 : 0;
}

#ifdef DEBUG
char *input_file, *output_file;
#endif

struct IO {
	static const int maxn = (1 << 25) + 10;

	char a[maxn], *s, b[maxn], *t;

	void INPUT() {
		s = a;
		t = b;
		#ifdef DEBUG
		FILE *f = fopen(input_file, "r");
		a[fread(a, 1, sizeof a, f)] = 0;
		#else
		a[fread(a, 1, sizeof a, stdin)] = 0;
		#endif
	}

	void OUTPUT() {
#ifdef DEBUG
		FILE *f = fopen(output_file, "w");
		fwrite(b, 1, t - b, f);
#else
		fwrite(b, 1, t - b, stdout);
#endif
	}

	operator int() {
		int x = 0;
		while(*s != '-' && (*s < '0' || *s > '9')) {
			++s;
		}
		bool f = 0;
		if(*s == '-') {
			f = 1;
			++s;
		}
		while(*s >= '0' && *s <= '9') {
			(x *= 10) += *s - '0';
			++s;
		}
		if(f) {
			x = -x;
		}
		return x;
	}

	operator LL() {
		LL x = 0;
		while(*s != '-' && (*s < '0' || *s > '9')) {
			++s;
		}
		bool f = 0;
		if(*s == '-') {
			f = 1;
			++s;
		}
		while(*s >= '0' && *s <= '9') {
			(x *= 10) += *s - '0';
			++s;
		}
		if(f) {
			x = -x;
		}
		return x;
	}

	operator char() {
		while(*s <= 32) {
			++s;
		}
		char ret = *s;
		++s;
		return ret;
	}

	inline void out(int x) {
		if(!x) {
			*t++ = '0';
			return;
		}
		if(x < 0) {
			*t++ = '-';
			x = -x;
		}
		static char c[20], *i;
		i = c;
		while(x) {
			int y = x / 10;
			*i++ = x - y * 10 + '0';
			x = y;
		}
		while(i != c) {
			*t++ = *--i;
		}
		return;
	}

	inline void out(int x, char C) {
		if(!x) {
			*t++ = '0';
			*t++ = C;
			return;
		}
		if(x < 0) {
			*t++ = '-';
			x = -x;
		}
		static char c[20], *i;
		i = c;
		while(x) {
			int y = x / 10;
			*i++ = x - y * 10 + '0';
			x = y;
		}
		while(i != c) {
			*t++ = *--i;
		}
		*t++ = C;
		return;
	}

	inline void out(LL x) {
		if(!x) {
			*t++ = '0';
			return;
		}
		if(x < 0) {
			*t++ = '-';
			x = -x;
		}
		static char c[20], *i;
		i = c;
		while(x) {
			LL y = x / 10;
			*i++ = x - y * 10 + '0';
			x = y;
		}
		while(i != c) {
			*t++ = *--i;
		}
		return;
	}

	inline void out(LL x, char C) {
		if(!x) {
			*t++ = '0';
			*t++ = C;
			return;
		}
		if(x < 0) {
			*t++ = '-';
			x = -x;
		}
		static char c[20], *i;
		i = c;
		while(x) {
			LL y = x / 10;
			*i++ = x - y * 10 + '0';
			x = y;
		}
		while(i != c) {
			*t++ = *--i;
		}
		*t++ = C;
		return;
	}

	inline void out(char c) {
		*t++ = c;
		return;
	}

	inline void out(char *s) {
		while(*s >= ' ') {
			*t++ = *s++;
		}
		return;
	}
}io;

void Main();

int main(int argc, char *argv[]) {
#ifdef DEBUG
	input_file = argv[1];
	output_file = argv[2];
#endif
	io.INPUT();
	Main();
	io.OUTPUT();
	return 0;
}

//---------------------------------------------------------------------------------------head---------------------------------------------------------------------------------------

int n, k, *p, *ans;

void update(int &x, int y) {
	x = (x == n || y < n && p[y] < p[x]) ? y : x;
	return;
}

struct node {
	node *ch[2];
	int num;

	node() {
		memset(ch, 0, sizeof num);
	}

	void pull() {
		num = n;
		rep(i, 2) {
			update(num, ch[i]->num);
		}
		return;
	}
}*root;

int seg_a, seg_b, seg_q;
set<int> heap;

void B(node* &u = root, int l = 0, int r = n - 1) {
	u = new node;
	if(l == r) {
		u->num = l;
		return;
	}
	int mid = l + r >> 1;
	B(u->ch[0], l, mid);
	B(u->ch[1], mid + 1, r);
	return u->pull();
}

void M(node* &u = root, int l = 0, int r = n - 1) {
	if(l == r) {
		u->num = seg_q;
		return;
	}
	int mid = l + r >> 1;
	if(seg_a <= mid) {
		M(u->ch[0], l, mid);
	}
	else {
		M(u->ch[1], mid + 1, r);
	}
	return u->pull();
}

void Q(node* &u = root, int l = 0, int r = n - 1) {
	if(seg_a <= l && r <= seg_b) {
		update(seg_q, u->num);
		return;
	}
	int mid = l + r >> 1;
	if(seg_a <= mid) {
		Q(u->ch[0], l, mid);
	}
	if(mid < seg_b) {
		Q(u->ch[1], mid + 1, r);
	}
	return;
}

void Main() {
	n = io;
	k = io;
	p = new int[n];
	ans = new int[n];
	rep(i, n) {
		p[i] = io;
	}
	B();
	for (int i = 0; i < n; i += k) {
		seg_a = i, seg_b = min(i + k, n) - 1;
		seg_q = n;
		Q();
		if(seg_q < n) {
			int i = seg_q;
			seg_a = max(0, i - k + 1), seg_b = min(n - 1, i + k - 1);
			seg_q = n;
			Q();
			if(i == seg_q) {
				heap.insert(i);
			}
		}
	}
	int cnt = 0;
	while(SZ(heap)) {
		int i = *heap.begin();
		ans[i] = ++cnt;
		heap.erase(heap.begin());
		seg_a = i;
		seg_q = n;
		M();
		i = i / k * k;
		seg_a = i, seg_b = min(i + k, n) - 1;
		seg_q = n;
		Q();
		if(seg_q < n) {
			int i = seg_q;
			seg_a = max(0, i - k + 1), seg_b = min(n - 1, i + k - 1);
			seg_q = n;
			Q();
			if(i == seg_q) {
				heap.insert(i);
			}
		}
		i -= k;
		if(i >= 0) {
			seg_a = i, seg_b = min(i + k, n) - 1;
			seg_q = n;
			Q();
			if(seg_q < n) {
				int i = seg_q;
				seg_a = max(0, i - k + 1), seg_b = min(n - 1, i + k - 1);
				seg_q = n;
				Q();
				if(i == seg_q) {
					heap.insert(i);
				}
			}
		}
		i += k + k;
		if(i >= 0 && i < n) {
			seg_a = i, seg_b = min(i + k, n) - 1;
			seg_q = n;
			Q();
			if(seg_q < n) {
				int i = seg_q;
				seg_a = max(0, i - k + 1), seg_b = min(n - 1, i + k - 1);
				seg_q = n;
				Q();
				if(i == seg_q) {
					heap.insert(i);
				}
			}
		}
	}
	rep(i, n) {
		io.out(ans[i], '\n');
	}
	return;
}


Measured memory_bytes: 70272