while True:
    try:
        num = input().split()
        num_1 = int(num[0])
        num_2 = int(num[1])
        a = input().split()
        b = []
        for i in a:
            b.append(int(i))
        b = sorted(b) #排序
        for i in range(num_2):
            print(b[i],end = ' ') #按格式输出
        print('\r')
    except:
        break