N, K = map(int, input().split()) A = list(map(int, input().split())) L, R = [], [] for i in range(N - 1): if A[i] <= A[i + 1]: L.append(i) else: R.append(i) R.append(N - 1) L.reverse() R += L pos = R[K - 1] ans = A[:pos] + A[pos+1:] print(*ans)