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 n-i < k: k = n-i if k == 1 and y < x: ans = i if y < x: 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)