m,n=map(int,input().split())
nums=list(map(int,input().split()))
nums.sort()
print(' '.join(str(i) for i  in nums[:n]))