n,k = map(int,input().split()) a = list(map(int,input().split())) ans = -1 for i in range(n-1): x,y = a[i], a[i+1] if k == 1 and y < x: ans = i elif y < x: k = max(1, k-1) if x < y and k >= n-i: ans = i if ans != -1: break if ans == -1: ans = n-1 b = [] for i in range(n): if i != ans: b.append(a[i]) print(*b)