#include <bits/stdc++.h>

using namespace std;

int n, k, a[500010], out = 0;
deque<int> q;
vector<int> b;

int main()
{
    scanf("%i%i", &n, &k);
    for (int i = 0; i < n; ++i)
        scanf("%i", &a[i]);
    for (int i = 0; i < n; ++i)
    {
        while (!q.empty() && q.back() > a[i] && out < k)
        {
            q.pop_back();
            out++;
        }
        q.push_back(a[i]);
        if (i >= k)
        {
            printf("%i ", q.front());
            q.pop_front();
        }
    }
    return 0;
}