n,k = input().split()
k = int(k)
num = list(map(int,input().split()))
num.sort()
for i in num[:k]:
    print(i,end=' ')