import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()

    val As = readInputLine().split(" ").mapIndexed{i, r -> r.toInt() - i - 1}.sorted()

    val differ = As[N / 2]
    
    println(As.fold(0L, {R, T -> R + Math.abs(T - differ)}))
}

fun readInputLine(): String {
    return readLine()!!
}
