#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, L; cin >> N >> L;
  vector<int> a(N); for (int i = 0; i < N; ++i) cin >> a[i];
  deque<int> deq;
  for (int i = 0; i < N; ++i) {
    while (!deq.empty() && a[deq.back()] >= a[i]) deq.pop_back();
    deq.push_back(i);

    if (i >= L - 1) {
      if (i != L - 1) cout << ' ';
      cout << a[deq.front()];
    }
    if (deq.front() == i - L + 1) deq.pop_front();
  }
  cout << endl;
  return 0;
}

