import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 0, k = 0;
        while (sc.hasNext()) {
            n = sc.nextInt();
            k = sc.nextInt();
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                list.add(sc.nextInt());
            }
            list.sort(null);
            for (int i = 0; i < k; i++) System.out.print(list.get(i) + " ");
        }
    }
}