def solve(n, k, p): top = [] bottom = [] p.append(0) for i in range(n): if p[i] < p[i + 1]: top.append(i) else: bottom.append(i) q = top + bottom[::-1] ind = q[k - 1] ans = [] for i in range(n): if i == ind: continue ans.append(p[i]) p.pop() return ans n, k = map(int,input().split()) p = list(map(int,input().split())) print(*solve(n, k, p))