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]
var ans = 0
for i in B {
  ans += abs($0-b)
}
print(ans)