#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int n,m,num[100024];
int cmp( const void *a,const void *b )
{
return *( int * )b - *( int * )a;
}
int main( )
{
while( scanf( "%d%d",&n,&m ) , n | m )
{
for( int i = 0; i < n; ++i )
scanf( "%d",&num[i] );
qsort( num,n,sizeof( num[0] ),cmp );
int j = n < m ? n : m;
for( int i = 0; i < j ; ++i )
i ? printf( " %d",num[i] ) : printf( "%d",num[i] );
puts( "" );
memset( num,0,sizeof( num ) );
}
return 0;
}
#include<stdlib.h>
#include<string.h>
int n,m,num[100024];
int cmp( const void *a,const void *b )
{
return *( int * )b - *( int * )a;
}
int main( )
{
while( scanf( "%d%d",&n,&m ) , n | m )
{
for( int i = 0; i < n; ++i )
scanf( "%d",&num[i] );
qsort( num,n,sizeof( num[0] ),cmp );
int j = n < m ? n : m;
for( int i = 0; i < j ; ++i )
i ? printf( " %d",num[i] ) : printf( "%d",num[i] );
puts( "" );
memset( num,0,sizeof( num ) );
}
return 0;
}