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((N%2>0 ?(N/2..<N).reduce(0){$0+B[$1]}:(N/2+1..<N).reduce(0){$0+B[$1]})-(0..<N/2).reduce(0){$0+B[$1})