#include<bits/stdc++.h>
using namespace std;
deque <int> a;
int main()
{
int n,k;
cin >> n >> k;
int cnt = 0;
for(int i = 1;i<=n;i++)
{
int x;
if(a.empty() == 0)
{
cnt++;
if(cnt == k)
{
cnt = 0;
a.pop_front();
}
cin >> x;
while(a.empty() == 0 && x > a.back())
{
if(a.size() == 1)
{
cnt = 0;
}
a.pop_back();
}
a.push_back(x);
if(i >= k)
{
cout << a.front() << '\n';
}
}
else
{
cin >> x;
a.push_back(x);
if(i >= k)
{
cout << a.front() << '\n';
}
}
}
return 0;
}
实在找不到问题