fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val a = readLine()!!.split(" ")
            .mapIndexed { index, s -> s.toLong()-(index+1) }
            .sorted()
    val med = a[n/2]

    a.map{ Math.abs(it-med) }
            .sum()
            .let{ println(it) }
}