while True:
    try:
        x1 = input().split()
        n = int(x1[0])
        k = int(x1[1])
        x2 = list(map(int,input().split()))
        x3 = sorted(x2)
        x4 = x3[0:k]
        x5 = []
        #将数值全部转化为字符串
        for word in x4:
            x5.append(str(word))
        print(' '.join(x5))
    except:
        break