import kotlin.math.abs
import kotlin.math.min

fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val n = readLine()?.toInt() ?: return
    val a = longList()
    val aa = 0.until(n).map {
        a[it] - (it + 1)
    }.sorted()
    if (n % 2 == 1) {
        val b = aa[n / 2]
        var sum1 = 0L
        0.until(n).forEach {
            sum1 += abs(a[it] - (it + 1 + b))
        }
        println(sum1.toString())
    } else {
        val b = aa[n / 2]
        val c = aa[n / 2 - 1]
        var sum1 = 0L
        var sum2 = 0L
        0.until(n).forEach {
            sum1 += abs(a[it] - (it + 1 + b))
            sum2 += abs(a[it] - (it + 1 + c))
        }
        println(min(sum1, sum2).toString())
    }
}