MAX = 2**31-1

def rmq(a, b, k, l, r, node)
  return MAX if r <= a || b <= l
  return node[k] if a <= l && r <= b
  m = (l+r)/2
  vl = rmq(a, b, 2*k+1, l, m, node)
  vr = rmq(a, b, 2*k+2, m, r, node)
  return vl < vr ? vl : vr
end

n, len = gets.split.map(&:to_i)
m = 1
while m < n
  m *= 2
end
node = Array.new(2*m-1){MAX}
arr = gets.split.map(&:to_i)

arr.size.times{|i|
  k = i + m - 1
  node[k] = arr[i]
  while k > 0
    k = (k-1)/2
    node[k] = node[2*k+1] < node[2*k+2] ? node[2*k+1] : node[2*k+2]
  end
}

i = len
j = 0

min = rmq(j, i, 0, 0, m, node)

print min

loop do
  break if i >= n

  i += 1
  j += 1
  min = rmq(j, i, 0, 0, m, node)
  print " #{min}"
end

puts