fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').mapIndexed { i, s -> s.toLong() - (i + 1) }.sorted()
    println(f(xs, xs[n / 2]))
}

private fun f(xs: List<Long>, b: Long): Long {
    return xs.map { Math.abs(it - b) }.sum()
}