mod = 998244353 def main(): import sys input = sys.stdin.readline N, K = map(int, input().split()) A = list(map(int, input().split())) ans = [-1] * N l = 0 r = N-1 for i in range(N-1): if A[i] < A[i+1]: ans[r] = i r -= 1 else: ans[l] = i l -= 1 for i in range(N-1): if ans[i] == -1: ans[i] = N - 1 B = [] for i in range(N): if i == ans[K - 1]: continue B.append(A[i]) print(*B) if __name__ == '__main__': main()