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

pos = {}
len.times{|i|
  pos[arr[i]] = i
}
min, idx = pos.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
    pos = {}
    len.times{|j|
      pos[arr[idx+1+j]] = idx+1+j
    }
    min, idx = pos.min
  end
  ans << min
  i += 1
end

puts ans.join(" ")