#include <iostream>
#include <algorithm>
using namespace std;

const int N = 100010;
int a[N];
int main() {
    int n, m;
    while (cin >> n >> m) {
        if(n==0&&m==0) break;
        for (int i = 0; i < n; i++) cin >> a[i];
        sort(a, a + n);
        if (m > n) {
            for (int i = n - 1; i >= 0; i--)
                cout << a[i] << " ";
            cout << endl;
        } else {
            for (int i = n - 1, k = 0; k < m; k++, i--)
                cout << a[i] << " ";
            cout << endl;
        }
    }

    return 0;
}