import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n, k = mi() a = li() q = deque([n - 1]) for i in range(n - 2, -1, -1): if a[i] < a[i+1]: q.append(i) else: q.appendleft(i) print(*(a[:q[k-1]] + a[q[k-1]+1:]))