#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
int n, k;
int arr[1001];
while(EOF != scanf("%d%d", &n, &k)) {
for(int i = 0; i < n; i++) {
scanf("%d", arr + i);
}
sort(arr, arr + n);
printf("%d", arr[0]);
for(int i = 1; i < k; i++) {
printf(" %d", arr[i]);
}
printf("\n");
}
return 0;
}