#include <bits/stdc++.h>
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 = {{ {0, 3}, {1, 1}, {2, 1}, {3, 3}, {4, 1} }};
    cout << s;
    s.del(0);
    s.add(0);
    cout << s;
    cout << "min: " << s.min() << endl;
}


int main()
{
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    int n, k; cin >> n >> k;
    vector<int> sol, vec; mset s;
    int br; while(n--) cin >> br, vec.push_back(br);
    int l=0, r=0; do
    {
        while(r-l <= k) s.add(vec[r++]);
        if(!s.empty()) sol.push_back(s.min());
        while(vec[l] != sol.back()) s.del(vec[l++]), k--;
        s.del(vec[l++]);
    } while(r<vec.size());
    for(auto& x : sol) cout << x << " ";
    return cout << endl, 0;
}