object Main extends App {
  import scala.io.StdIn._
  import scala.math
  val Array(n, m, k) = readLine.trim.split(' ').map(_.toInt)
  val oranges = List.tabulate(n){_ ⇒ readLine.trim.toInt}
  implicit val memo: Array[Option[Long]] = Array.tabulate(n + 1){_ ⇒ None}
  println(
    dp(oranges, n, m, k)
  )
  def dp(oranges: List[Int], length:Int, m: Int, k: Int)(implicit memo: Array[Option[Long]]): Long = {
    oranges match{
      case Nil ⇒ 0
      case h::t ⇒
        memo(length) match{
          case Some(v) ⇒ v
          case None ⇒ dp(t, 1, h, h, m, k, length - 1).also(it ⇒ memo(length) = Some(it))
        }
    }

  }
  def dp(oranges: List[Int], count: Long, max: Int, min: Int, m: Int, k: Int, length: Int): Long = {
    if (count == m) dp(oranges, length, m, k) + k + count * (max - min)
    else {
      oranges match {
        case Nil ⇒ k + count * (max - min)
        case h :: t if max < h ⇒ math.min(dp(oranges, length, m, k) + k + count * (max - min), dp(t, count + 1, h, min, m, k, length - 1))
        case h :: t if min > h ⇒ math.min(dp(oranges, length, m, k) + k + count * (max - min), dp(t, count + 1, max, h, m, k, length - 1))
        case _ :: t ⇒ math.min(dp(oranges, length, m, k) + k + count * (max - min), dp(t, count + 1, max, min, m, k, length - 1))
      }
    }
  }
  implicit class ScopeFunc[T](private val value: T) {
    def let[A](func:T ⇒ A): A = func(value)
    def also(func:T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}


