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

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

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

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

  println(ans)
}