from queue import PriorityQueue que = PriorityQueue() m, n = map(int, input().split()) arr = list( map(int, input().split()) ) for val in arr: que.put(val) for i in range(n): print(que.get(), end=' ') print()