from collections import deque n, t = map(int, input().split()) a = list(map(int, input().split())) que = deque([*range(n)]) ans = [-1] * n for i in range(n - 1): if(a[i] <= a[i + 1]): ans[que.pop()] = i else: ans[que.popleft()] = i for i in range(n): if(ans[i] == -1): ans[que.pop()] = n - 1 x = ans[t - 1] lis = [] for i, k in enumerate(a): if(i == x): continue lis.append(k) print(*lis)