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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n, k;
    cin >> n >> k;
    pair<long long, long long> a[n];
    bool t[n];
    for(long long i=0;i<n;i++){
        cin >> a[i].first;
        a[i].second=i;
        t[i]=false;
    }
    sort(a, a+n);

    /*for(long long i=0;i<n;i++){
        cout << a[i].first << a[i].second << " ";
    }*/
    //cout << endl;
    long long r[n], br=0, l=0, d=k;
    for(long long i=0;i<n-k;i++){
        //long long m=1000000001, mi=0;
        //cout << l << " " << d << endl;
        for(long long j=0;j<n;j++){
            if(t[j]==true){
                continue;
            }
            if(a[j].second<=d&&a[j].second>=l){
                r[br]=a[j].first;
                br++;
                l=1+a[j].second;
                d++;

                continue;
            }
        }
    }

    for(long long i=0;i<n-k;i++){
        cout << r[i] << " ";
    }
    return 0;
}