func ABS(x:Int)->Int{return x>0 ?x:-x}
let N = Int(readLine()!)!
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
let B = (1...N).map{A[$0-1]-$0}
let b = B.sort()[N/2]
print(B.reduce(0){$0+ABS($1-b)})