a,b=input().split( ),input().split( ) c=int(a[1]) b= [int(x) for x in b] b.sort() d= b[:c] print(' '.join(map(str,d)))