import scala.io.StdIn

object Main extends App {

  def solv(pd: Long) = aind.foldLeft(0L)((acc, ai) => acc + scala.math.abs(ai._1 - (pd + ai._2 + 1)))

  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ").map(_.toLong)
  val aind = a.zipWithIndex

  //val r = aind.map( ai => scala.math.abs(ai._1 - (ai._2 + 1)))
  val r = aind.map(ai => ai._1 - (ai._2 + 1))
  //println(r.mkString(" "))
  //val ds = r.distinct.sorted
  val ds = r.sorted
  //println(ds.mkString(" "))
  val c = ds.length
  val r1 = if (c % 2 == 0) {
    //println("s1 :" + solv(ds(c / 2 - 1)))
    //println("s2 :" + solv(ds(c / 2)))

    scala.math.min(solv(ds(c / 2 - 1)), solv(ds(c / 2)))
  } else {
    solv(ds(c / 2))
  }


  println(r1)

  //val mina = for(d <- ind) yield solv(pd)

  //println(mina.toList.mkString(" "))

  //println(mina.min)

}
