# 两个整数n和k
line = input()
n, k = map(int, line.split(" "))

# 一个整数数组
line = input()
arr = list(map(int, line.split(" ")))

arr.sort()
for i in range(k):
    print(arr[i], end=" ")