a,b=map(int,input().split()) c=[] for i in map(int,input().split()): c.append(i) c.sort() for i in range(b): print(c[i],end=" ")