while True:

	try:
	
	    m, n = [int(i) for i in input().split()]
	    num_list = [int(j) for j in input().split()]
	    
	    num_list.sort()
	    new_list = num_list[:n]
	    print(' '.join([str(i) for i in new_list]))
	    
	except:
	    break