#include "bits/stdc++.h"
using namespace std;
using ll = long long;
 
#ifdef LOCAL
#include "debug.h"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#else
#define debug(...) 42
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int& x : a) { cin >> x; }
    sort(begin(a), end(a));
    reverse(begin(a) + n-k, end(a));
    int cnt = 0;
    for(int i = n-1; i >= 0; --i) {
        if(cnt < a[i]) {
            cnt++;
        }
    }
    debug(a, cnt);
    if(cnt != k) {
        cout << "-1\n";
        return;
    }
    for(int x : a) {
        cout << x << ' ';
    }
}
 
signed main(){
    #ifdef LOCAL
    freopen("test.err", "w", stderr);
    #endif
    cin.tie(0)->sync_with_stdio(0);
    signed T = 1;
    // cin >> T;
    for(signed test = 1; test <= T; ++test){
        solve();
    }
} 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |