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