n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
print(" ".join(str(x) for x in a[:k]))