from collections import deque n,k=map(int,input().split()) a=list(map(int,input().split())) dq=deque() dq.append(n-1) top=True for i in range(n-2,-1,-1): if a[i]a[i+1]: dq.appendleft(i) top=True else: if top: dq.appendleft(i) else: dq.append(i) ng=dq[k-1] ans=a[:ng]+a[ng+1:] print(*ans)