while True: try: n1,n2 = list(map(int,input().split())) value = sorted(list(map(int,input().split()))) #print() print(*value[:n2]) except: break