import kotlin.math.abs

fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }

    val b = bestB(a)
    var sum = 0L
    for (i in 1..n) sum += abs(a[i - 1].toLong() - b - i)
    println(sum)
}

private fun bestB(a: List<Int>): Int {
    val n = a.size
    var high = (1..n).map { a[it - 1] - it }.max()!! + 1
    var low = (1..n).map { a[it - 1] - it }.min()!!

    while (high - low > 1) {
        val mid = (high + low) / 2

        val big = (1..n).count { a[it - 1] < mid + it }
        val small = (1..n).count { a[it - 1] > mid + it }

        if (big > small) high = mid
        else low = mid
    }
    return low
}