n,k=map(int,input().split()) a=list(map(int,input().split())) front=[] back=[] res=[] for i in range(n-1): if a[i]a[i+1]: res.append(i) for j in res: front.append(j) res=[] else: res.append(i) ord=front+res+[n-1]+back[::-1] ng=ord[k-1] ans=a[:ng]+a[ng+1:] print(*ans)