import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object ABC102C extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toInt)

  val c = a.zipWithIndex.map { case (a, i) => a - (i+1) }.sorted
  val b = c(n/2)

  val ans = a./:(0L, 1L){ case ((acc, idx), ai) =>
    (acc + (ai - (b + idx)).abs, idx + 1L)
  }._1

  println(ans)
}