n, len = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)

min = arr[0,len].min
idx = arr.index(min)

ans = [min]
i = len
loop do
  break if i >= n
  if min >= arr[i] then
    min = arr[i]
    idx = i
  elsif idx == i - len then # drop out minimum number from the window
    min = arr[idx+1,len].min
    idx += arr[idx+1,len].index(min) + 1
  end
  ans << min
  i += 1
end

puts ans.join(" ")