n,k=map(int,input().split()) A=list(map(int,input().split())) A.append(0) start=0 end=n+1 for q in range(n): if A[q]>=A[q+1]: start+=1 else: end-=1 if start==k or end==k: del A[n] del A[q] print(*A) exit()