private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun shiftSumAbs(a: List<Int>, shift: Int) = a.map { Math.abs(it - shift).toLong() }.sum()

fun main(args: Array<String>) {
    val N = readInts()[0]
    val A = readInts()
    val shifted = A.mapIndexed { index, num -> num - index - 1 }
    println(shiftSumAbs(shifted, shifted.sorted()[N / 2]))
}