import java.io.*;
import java.util.*;

public class battle_av {

	FastScanner in;
	PrintWriter out;
	final String fileName = "battle";

	void solve() {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = readPermutation(n);
		int[] b = getInversions(a);
		
		
		if (n > 2000) {
			long countStupid = (long) n * (long) k;
			if (countStupid < 3e8) {
				throw new AssertionError("This test pretends to be hard, but it's not. Reason: n * k = " + countStupid);
			}
		}

		for (int i = 0; i < n; i++) {
			b[i] = Math.max(0, b[i] - k);
		}
		a = restore(b);
		writePermutation(a);
		if (n > 2000) {
			if (isSorted(a)) {
				throw new AssertionError("This test pretends to be hard, but it's not. Reason: array is sorted afterwards");
			}
		}
	}
	
	private boolean isSorted(int[] a) {
		for (int i = 0; i < a.length - 1; i++) {
			if (a[i] > a[i + 1]) {
				return false;
			}
		}
		return true;
	}

	int[] getInversions(int[] a) {
		int n = a.length;
		final int[] b = new int[n];
		class MergeSorter {
			int[] tmp;

			public void mergeSort(int[] a) {
				tmp = new int[a.length];
				mergeSort(a, 0, a.length);
			}

			private void mergeSort(int[] a, int l, int r) {
				if (l + 1 == r) {
					return;
				}
				int mid = (l + r) >> 1;
				mergeSort(a, l, mid);
				mergeSort(a, mid, r);

				int p1 = l, p2 = mid;
				int p = 0;
				while (p1 < mid && p2 < r) {
					if (a[p1] < a[p2]) {
						tmp[p++] = a[p1++];
					} else {
						b[a[p2]] += (mid - p1);
						tmp[p++] = a[p2++];
					}
				}

				while (p1 < mid) {
					tmp[p++] = a[p1++];
				}

				while (p2 < r) {
					tmp[p++] = a[p2++];
				}

				System.arraycopy(tmp, 0, a, l, r - l);
			}
		}
		new MergeSorter().mergeSort(a);
		return b;
	}
	
	class SegmentTree {
		int n;
		int[] tree;
		public SegmentTree(int n) {
			this.n = n;
			this.tree = new int[4 * n];
			build(0, n, 0);
		}
		
		private void build(int l, int r, int i) {
			if (l + 1 == r) {
				tree[i] = 1;
				return;
			}
			int m = (l + r) >> 1;
			build(l, m, 2 * i + 1);
			build(m, r, 2 * i + 2);
			update(i);
		}

		private void update(int i) {
			tree[i] = tree[2 * i + 1] + tree[2 * i + 2];
		}
		
		public void set(int pos, int val){ 
			set(0, n, pos, val, 0);
		}
		
		private void set(int l, int r, int pos, int val, int i) {
			if (l + 1 == r) {
				tree[i] = val;
				return;
			}
			int m = (l + r) >> 1;
			if (pos < m) {
				set(l, m, pos, val, 2 * i + 1);
			} else {
				set(m, r, pos, val, 2 * i + 2);
			}
			update(i);
		}
		
		public int find(int value) {
			return find(0, n, value, 0);
		}
		
		private int find(int l, int r, int value, int i) {
			if (l + 1 == r) {
				return l;
			}
			int m = (l + r) >> 1;
			int sumLeft = tree[2 * i + 1];
			if (sumLeft >= value) {
				return find(l, m, value, 2 * i + 1);
			} else {
				return find(m, r, value - sumLeft, 2 * i + 2);
			}
		}
	}

	private int[] restore(int[] b) {
		int n = b.length;
		SegmentTree tree = new SegmentTree(n);
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			int pos = tree.find(b[i] + 1);
			a[pos] = i;
			tree.set(pos, 0);
		}
		return a;
	}

	int[] readPermutation(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt() - 1;
		}
		return a;
	}

	void writePermutation(int[] a) {
		for (int i = 0; i < a.length; i++) {
			out.print(a[i] + 1);
			if (i + 1 == a.length) {
				out.println();
			} else {
				out.print(' ');
			}
		}
	}

	void run() {
		try {
			in = new FastScanner(fileName + ".in");
			out = new PrintWriter(fileName + ".out");
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] args) {
		new battle_av().run();
	}
}
