let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string |> Array.of_list
let a = Array.init n @@ fun i -> a.(i) - i - 1

let () = 
  Array.sort compare a;
  Printf.printf "%d\n" @@ Array.fold_left (fun sum i -> sum + abs (i - a.(n / 2))) 0 a