#include <cassert>
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <utility>
#include <vector>

std::size_t bsr32(std::uint_fast32_t c) {
#ifdef __GNUC__
	return 31 ^ __builtin_clz(c);
#else
	std::size_t ret = 0;
	if (c & 0xFFFF0000)
		c &= 0xFFFF0000, ret |= 16;
	if (c & 0xFF00FF00)
		c &= 0xFF00FF00, ret |= 8;
	if (c & 0xF0F0F0F0)
		c &= 0xF0F0F0F0, ret |= 4;
	if (c & 0xCCCCCCCC)
		c &= 0xCCCCCCCC, ret |= 2;
	if (c & 0xAAAAAAAA)
		ret |= 1;
	return ret;
#endif
}

template <class Semigroup> class DisjointSparseTable {
public:
	using container_type = std::vector<std::vector<Semigroup>>;
	using value_type = typename container_type::value_type::value_type;
	using const_reference = typename container_type::value_type::const_reference;
	using size_type = typename container_type::value_type::size_type;

protected:
	container_type c;

private:
	template <class TT = value_type,
		std::enable_if_t<std::is_default_constructible<TT>::value,
		std::nullptr_t> = nullptr>
		value_type fold_(size_type first, size_type last) const {
		assert(first <= size());
		assert(last <= size());
		assert(first <= last);
		if (first == last)
			return value_type();
		if (first == --last)
			return c.front()[first];
		const size_type h = bsr32(first ^ last);
		return c[h][first] + c[h][last];
	}
	template <class TT = value_type,
		std::enable_if_t<!std::is_default_constructible<TT>::value,
		std::nullptr_t> = nullptr>
		value_type fold_(size_type first, size_type last) const {
		assert(first < size());
		assert(last <= size());
		assert(first < last);
		if (first == --last)
			return c.front()[first];
		const size_type h = bsr32(first ^ last);
		return c[h][first] + c[h][last];
	}

public:
	DisjointSparseTable() : c() {}
	template <class InputIterator>
	DisjointSparseTable(InputIterator first, InputIterator last) : c() {
		c.emplace_back(first, last);
		const size_type s = c.front().size();
		if (!s)
			c.clear();
		else
			c.resize(s == static_cast<size_type>(1) ? 1 : (bsr32(s - 1) + 1));
		typename container_type::value_type temp;
		temp.reserve(s);
		for (size_type i = 1; i < c.size(); ++i) {
			const size_type width = static_cast<size_type>(1) << i;
			for (size_type j = width; j < s; j += width << 1) {
				temp.emplace_back(c.front()[j - 1]);
				for (size_type k = 2; k <= width; ++k)
					temp.emplace_back(c.front()[j - k] + temp.back());
				for (size_type k = width - 1; ~k; --k)
					c[i].emplace_back(std::move(temp[k]));
				temp.clear();
				c[i].emplace_back(c.front()[j]);
				for (size_type k = 1; k < width && j + k < s; ++k)
					c[i].emplace_back(c[i].back() + c.front()[j + k]);
			}
		}
	}
	DisjointSparseTable(const typename container_type::value_type &x)
		: DisjointSparseTable(x.cbegin(), x.cend()) {}

	size_type size() const { return c.empty() ? 0 : c.front().size(); }
	bool empty() const { return c.empty(); }

	const_reference operator[](const size_type index) const {
		assert(index < size());
		return c.front()[index];
	}
	value_type fold(const size_type first, const size_type last) const {
		return fold_(first, last);
	}
};

#include<limits>
#include<utility>
#include<algorithm>

template <class T> class Mini {
public:
	using value_type = T;

protected:
	value_type a;

public:
	Mini() : a(std::numeric_limits<value_type>::max()) {}
	explicit Mini(const value_type &x) : a(x) {}
	explicit Mini(value_type &&x) : a(std::move(x)) {}
	Mini operator+(const Mini &o) const { return Mini(std::min(a, o.a)); }
	explicit operator value_type &() { return a; }
	explicit operator const value_type &() const { return a; }
	explicit operator value_type && () { return std::move(a); }
	value_type value() const { return a; }
};

#include<iostream>
#include<vector>

int main() {
	using uint = unsigned int;
	using M = Mini<uint>;
	uint n, l;
	std::cin >> n >> l;
	std::vector<M> a(n);
	for (auto &e : a)
		std::cin >> static_cast<uint &>(e);
	DisjointSparseTable<M> D(a);
	for (uint i = 0;i <= n - l;++i)
		std::cout << D.fold(i, i + l).value() << " \n"[i == n - l];
	return 0;
}


Measured memory_bytes: 89076