import sys input = sys.stdin.readline N,K=map(int,input().split()) A=list(map(int,input().split())) ANS=[-1]*N last=N-1 first=0 for i in range(N-1): if A[i]>A[i+1]: ANS[first]=i first+=1 while i-1>=0 and A[i]==A[i-1]: i-=1 ANS[first]=i first+=1 elif A[i]=0 and A[i]==A[i-1]: i-=1 ANS[last]=i last+=1 x=ANS[K-1] if x==-1: print(*A[:-1]) else: print(*A[:x]+A[x+1:])