m,n = map(int,input().split())
print(' '.join(map(str,sorted(list(map(int,input().split())))[0:n])))