#include "bits/stdc++.h"

using namespace std;

void solve()
{
    int n, l;
    cin >> n >> l;
    vector<int> as(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    deque<pair<int, int>> dq;
    for (int i = 0; i < n; i++)
    {
        deque<pair<int, int>> ndq(dq);
        if (!dq.empty())
        {
            for (auto p : dq)
            {
                if (p.first >= as[i])
                {
                    ndq.pop_front();
                }
                else
                {
                    break;
                }
            }
        }
        ndq.push_front(make_pair(as[i], i));
        if (i + 1 >= l)
        {
            cout << ndq.back().first << " \n"[i == n - 1];
        }
        if (ndq.back().second == i - l + 1)
        {
            ndq.pop_back();
        }
        swap(dq, ndq);
    }
}

int main()
{
    solve();
    return 0;
}

