#include <bits/stdc++.h>
#define cons 131313

using namespace std;

struct mset
{
    set<pair<int, int>> s;
    void del(int x)
    {
        auto br = s.upper_bound({x, -1});
        if(br->first == x) 
            if(br->second == 1) s.erase(br);
            else s.insert({x, br->second-1}), s.erase(br);
    }

    void add(int x)
    {
        auto br = s.upper_bound({x, -1});
        if(br->first != x) s.insert({x, 1});
        else s.insert({x, br->second+1}), s.erase(br); 
    }

    bool empty() { return s.empty(); }
    int  min() { return s.begin()->first; }

    friend ostream& operator << (ostream& os, mset& s)
    {
        for(auto& x : s.s) for(int i=0; i<x.second; i++) 
        os << x.first << " "; return os << endl; 
    }
};

void __msetTest()
{
    mset s = {{{1, 3}, {2, 1}, {3, 3}, {4, 1}}};
    cout << s;
    s.del(3);
    s.add(2);
    cout << s;
    cout << "min: " << s.min() << endl;
}


int main()
{
    int n, k; cin >> n >> k;
    vector<int> sol, vec; mset s;
    int br; while(n--) cin >> br, vec.emplace_back(br+cons);
    int l=0, r=0, nl=0, nr=k+1; while(nl <= vec.size())
    {
        for(int i=l; i<nl; i++) s.del(vec[i]);
        for(int i=r; i<nr; i++) s.add(vec[i]);
        l = nl; r = nr; if(!s.empty()) sol.emplace_back(s.min());
        while(nl < vec.size() && vec[nl] != sol.back())
            nl++, k--; nl++;
        nr = min(nl + k + 1, (int)vec.size());
    }
    assert(vec.size()-k == sol.size());
    for(auto& x : sol) cout << x-cons << " "; cout << endl;
    return 0;
}