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

print min
i = len
loop do
  break if i >= n

  # slide window
  pos[arr[i]] = i
  pos.delete(arr[i-len]) if pos[arr[i-len]] == i-len

  if min >= arr[i] then
    min = arr[i]
    idx = i
  elsif idx == i - len then
    min, idx = pos.min
  end
  print " #{min}"
  i += 1
end

puts