import java.util.*;

public class Main {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
while (sc.hasNext()){
String aAb = sc.nextLine();
String[] array= aAb.split(" " );
int len = Integer.parseInt(array[0]);
int or = Integer.parseInt(array[1]);
int[] result = new int[len];
String temp = sc.nextLine();
String[] temarr= temp.split(" " );
for (int i = 0; i < temarr.length; i++) {
result[i]=Integer.parseInt(temarr[i]);
}
Arrays.sort(result);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < or; i++) {
sb.append(result[i]).append(" ");
}
System.out.println(sb.toString());
}

}

}