#include <iostream>
#include <deque>

std::deque<std::pair<int, int>> dq;

int main() {
  dq.clear();
  int n, l;
  std::cin >> n >> l;
  bool f = true;
  for (int i = 0; i < n; ++i) {
    int x;
    std::cin >> x;
    while (!dq.empty() && (i - dq.front().second >= l)) dq.pop_front();
    while (!dq.empty() && (dq.back().first > x)) dq.pop_back();
    dq.push_back({x, i});
    if (i >= l - 1) {
      if (!f) std::cout << " ";
      f = false;
      std::cout << dq.front().first;
    }
  }
  std::cout << std::endl;
  return 0;
}
