from queue import PriorityQueue n, k = map(int, input().split()) arr = list(map(int, input().split())) min_heap = PriorityQueue() for val in arr: min_heap.put(val) for _ in range(k-1): min_heap.get() print(min_heap.get())