// define Bn := {an - n - 1}
// question: minimize sum of abs of {bn - c} with suitable c
// answer: c should be the mode of B

let n = stdin.ReadLine() |> int

let bs = stdin.ReadLine().Split() 
           |> Array.mapi (fun i x -> (int x)-i-1)
           |> Array.sort

let c = bs.[n/2]

printfn "%d" (bs |> Array.map (fun x -> abs (x-c)) |> Array.sum)