
object Main extends App {

  import scala.io.StdIn._

  val Array(n, d) = readLine.trim.split(' ').map(_.toInt)
  val cities = readLine.trim.split(' ').map(_.toLong).zipWithIndex
  println(minCost(cities.reverse.toList))
  def minCost(cities: List[(Long, Int)]): Long = {
    def sub(list: List[(Long, Int)], current: Long, result: Long = 0): Long = {
      list match {
        case (a, b)::t if a + b * d > current ⇒ sub(t, current, current + a - b * d + result)
        case (a, b)::t ⇒ sub(t, a + b * d, current + a - b * d + result)
        case Nil ⇒ result
      }
    }
    sub(cities.tail, cities.head.let{case (a, b) ⇒ a + b * d})
  }

  class UnionFindTree{
    private var mParent: Option[UnionFindTree] = None
    private var mSize: Int = 1
    private def parent: UnionFindTree = {
      mParent.map{_.parent} match {
        case None ⇒ this
        case c@Some(p) ⇒
          mParent = c
          p
      }
    }
    def isSameUnion(that: UnionFindTree): Boolean = {
      parent == that.parent
    }
    def merge(that: UnionFindTree): Unit = {
      if (!isSameUnion(that)){
        val p = parent
        val tp = that.parent
        if (p.mSize > tp.mSize){
          tp.mParent = Some(p)
          p.mSize += tp.mSize
        }else {
          p.mParent = Some(tp)
          tp.mSize += p.mSize
        }
      }
    }
  }
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}