#include<bits/stdc++.h>
using namespace std;
int binarysearch(int arr[], int l, int r, int x)
{
if (r >= l) {
int mid = l + (r - l) / 2;
if (arr[mid] == x)
return mid;
if (arr[mid] > x)
return binarysearch(arr, l, mid - 1, x);
return binarysearch(arr, mid + 1, r, x);
}
return -1;
}
int main () {
int n;
long long int k;
cin >> n;
cin >> k;
int* arr = new int[n];
for(int i = 0 ; i < n ; i++)
{
cin >> arr[i];
}
if(k > n)
{
sort(arr, arr+n, greater());
}
else
{
int p = n;
int m = 0;
while(k > 0)
{
if(arr[m] == p)
{
p = p - 1;
m = m + 1;
}
else
{
int l = binarysearch(arr , m , n , p);
int temp;
temp = arr[m];
arr[m] = arr[l];
arr[l] = temp;
p = p - 1;
m = m + 1;
k = k - 1;
}
}
}
for(int i = 0 ; i < n ; i++)
{
cout << arr[i] << "\n";
}
return 0;
}