let score xs b = Array.mapi (fun i x -> abs (x - i - 1 - b)) xs |> Array.sum

let n = stdin.ReadLine() |> int
let xs = stdin.ReadLine().Split() |> Array.map int
let st = (Array.min xs) - n - 1
let en = (Array.max xs) + n + 1

seq { st..en }
|> Seq.map (score xs)
|> Seq.min
|> printfn "%d"
