fun main(args: Array<String>) {
    val n = readLine()?.toLong() ?: return
    val aList = readLine()?.split(" ")?.map { it.toLong() } ?: return

    val distList = aList.mapIndexed { index, l -> index - l + 1 }
    val median = distList.sorted()[((n - 1) / 2).toInt()]
    val result = distList.map { Math.abs(it - median) }.sum()

    println(result)
}