import java.util.Scanner
import scala.collection.mutable.Queue

object Main extends App { 
  val sc = new Scanner(System.in)
  val N, L = sc.nextInt()
  val An = (for (i <- 0 until N) yield sc.nextInt()).toArray
  val que = Queue[Int]()

  def enque(i:Int):Unit = {
    if (!que.isEmpty) {
      if (que.head <= i -L) que.dequeue()
      if (!que.isEmpty && An(que.last) >= An(i)) que.dequeueAll(An(_) >= An(i))
    }
    que += i
  }

  def solver(i:Int, acc:List[Int]):List[Int] = {
    if (i == N) acc.reverse
    else {
      enque(i)
      solver(i+1, An(que.head)::acc)
    } 
  }

  for (i <- 0 until L) enque(i)
  println(solver(L, List(An(que.head))).mkString(" "))
}

