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