#include <stdio.h>
#include <stdlib.h>
int compare(const void* a, const void* b) {
    const int* inta = (const int*)a;
    const int* intb = (const int*)b;
    return *inta - *intb;
}

int main() {
    int n, k;
    while (scanf("%d %d", &n, &k) != EOF) { 
        int arr[n];
        for(int i = 0; i < n; i++) {
            scanf("%d", &arr[i]);
        }
        qsort(arr, n, sizeof(int), compare);
        for(int i = 0; i < k - 1; i++) {
            printf("%d ", arr[i]);
        }

        printf("%d\n", arr[k - 1]);
    }
    return 0;
}