#include <iostream>
#include <vector>
//#include <set>

using namespace std;

static int n, k;
static vector<int> a;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    a.reserve(n);
    while (n--)
    {
        int broj;
        cin >> broj;
        a.push_back(broj);
    }
    //set<int> b(a.begin(), a.end());
    {
        int i = 0;
        while (k && (i != a.size()))
        {
            int asd = 1;
            auto j = i;
            int m = a[i], masd = 0;
            for (j++; (asd <= k) && (j != a.size()); j++, asd++)
            {
                if (a[j] < m)
                {
                    m = a[j];
                    masd = asd;
                }
            }
            if (masd != 0)
            {
                auto aaaaaaaaaaaaaaaaa = a.begin() + i;
                a.erase(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa + masd);
                k -= masd;
            }
            else
                i++;
        }
    }
    if (k)
    {
        auto i = a.end();
        while (k--)
        {
            a.erase(--i);
            i = a.end();
        }

    }
    for (auto n : a)
        cout << n << " ";
    return 0;
}