import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
HashMap<Integer, Integer> vi = new HashMap<>();
ArrayList<Integer> a = new ArrayList<>();
for (int i = 0; i < n; i++) {
a.add(sc.nextInt());
}
for (int i = 0; i < n; i++)
{
vi.put(a.get(i), i);
}
if (k >= n) {
Collections.sort(a,Collections.reverseOrder());
for (int x : a) {
System.out.print(x + " ");
}
} else {
for (int i = n; i > 0; i--) {
if (k > 0) {
int ii = vi.get(i);
int bi = n - i;
if (ii != bi) {
vi.put(i, bi);
int e = a.get(bi);
vi.put(e, ii);
int t = a.get(bi);
a.set(bi, a.get(ii));
a.set(ii, t);
}
k--;
}
}
for (int x : a) {
System.out.print(x + " ");
}
}
}
}