while True:
    try:
        opt = input().split()
        n = int(opt[1])
        nums = list(map(int, input().split()))
        lst = sorted(nums)[0:n]
        print(' '.join(map(str, lst)))
    except:
        break