public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            ArrayList<Integer> list = new ArrayList<>();
            int n = sc.nextInt();
            int k = sc.nextInt();
            String sk = sc.nextLine();
            String s = sc.nextLine();
            String[] ss = s.split(" ");
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = Integer.parseInt(ss[i]);
                list.add(nums[i]);
            }
            Collections.sort(list);
            for (int i = 0; i < k; i++) {
                if(i == k-1){
                    System.out.println(list.get(i));
                    break;
                }
                System.out.print(list.get(i)+" ");
            }
        }
    }
}