n,k=[int(x) for x in input().split()] list1=[int(x) for x in input().split()] for x in sorted(list1)[0:k]: print(x,end=' ')