#include <cstdio>

int n , k , i , p , b , A[500010] , B[5000010];

int Min(int x , int y)
{
    if (x < y) return x;
    return y;
}

int Poz(int x , int y)
{
    int m = A[x];
    int p = x;
    for (int i = x + 1;i <= y;++i)
    {
        if (A[i] < m)
        {
            m = A[i];
            p = i;
        }
    }
    return p;
}

int main()
{
    scanf("%d%d" , &n , &k);
    for (i = 1;i <= n;++i)
    {
        scanf("%d" , &A[i]);
    }
    i = Poz(1 , Min(k + 1 , n));
    k -= i - 1;
    while (i <= n)
    {
        B[++b] = A[i];
        p = Poz(i + 1 , Min(i + k + 1 , n));
        k -= p - i - 1;
        i = p;
    }
    for (int i = 1;i <= b - k;++i)
    {
        printf("%d " , A[i]);
    }
    return 0;
}