fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ")
            .mapIndexed { index, s -> s.toLong() - (index + 1) }
            .sorted()
            .apply { println(map { Math.abs(it - get(N/2)) }.sum()) }
}