import sys
while True:
    try:
        n, k = map(int, input().strip().split())
        L = list(map(int, input().strip().split()))
        L.sort()
        print(" ".join(map(str,L[:k])))
    except:
#         print(sys.exc_info())
        break