#include<stdio.h>
#include<stdlib.h>

int cmpFun(int* a,int* b)
{
    return *a - *b;
}

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