#include<iostream>#include<string>#include<math.h>#include<algorithm>usingnamespace std;int a[10005];int b[10005];boolcompare(int x,int y){return x > y;}voidarrangeRight(int l,int r,int m){if(l >= r)return;int k = a[l];int low = l, high = r;while(low != high){while(low < high && a[high]>= k)
high--;swap(a[low], a[high]);while(low < high && a[low]<= k)
low++;swap(a[low], a[high]);}if(r - low +1== m)return;elseif(r - low +1> m)arrangeRight(low +1, r, m);elsearrangeRight(l, low -1, m -(r - low +1));}intmain(){int n, m;
cin >> n >> m;for(int i =0; i < n; i++){
cin >> a[i];}arrangeRight(0, n -1, m);int count =0;for(int i = n - m; i < n; i++) b[count++]= a[i];sort(b, b + m, compare);for(int i =0; i < m; i++){
cout << b[i]<<" ";}}