n,k = map(int,input().split()) num = list(map(int,input().split())) num.sort() print(" ".join(map(str,num[:k])))