#include <functional>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> int(a); )
#define trav(i,v) for(auto&i:v)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
int main(){
cin.tie(0);
cin.sync_with_stdio(0);
cin.tie(0);
cin.sync_with_stdio(0);
int n,k;
cin >> n >> k;
vi v(n);
trav(i,v) cin >> i;
map<int,int> C;
Tree<int> T;
auto add = [&](int a){
if(C[a]++) return;
T.insert(a);
}, rem = [&](int a){
if(--C[a]) return;
T.erase(T.find(a));
};
rep(i,0,k) add(v[i]);
rep(i,k,n+1){
int m = 0;
for(int j = k/2; j > 0; j >>= 1)
while(m+j < k && !(T.find(m+j) == T.end()) && T.order_of_key(m+j) == m+j)
m += j;
cout << m+1 << " ";
if(i < n){
add(v[i]);
rem(v[i-k]);
}
}
cout << endl;
}