import java.util.Scanner
import scala.math.{abs, min}

object Main{
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt
    val a = List.fill(n)(sc.nextInt)
    var b = List.empty[Int]
    (0 to a.size-1).foreach{ i =>
      b = b ::: List(a.apply(i)-(i+1))
    } 
    b = b.sorted
    val median = b.apply(n/2)
    var res = 0
    (0 to a.size-1).foreach{ i =>
      res = res + abs(a.apply(i)-(median+i+1))
    }
    println(res)
  }
}