while True: try: n,k = map(int,input().split()) val = list(map(int,input().split())) val.sort() print(*val[0:k]) except: break