open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_l = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let l = List.mapi (fun i x -> x-i-1) a_l in

  let median l = 
    let l_s = List.sort compare l in
    let len = List.length l in

    if len mod 2 <> 0 then
      List.nth l_s (len/2)
    else
      (
        List.nth l_s (len/2) + List.nth l_s (len/2-1)
      )/2
  in
  let med = median l in

  let ans = 
    List.map (fun x -> abs(x-med)) l |>
    List.fold_left (+) 0
  in

  Printf.printf "%d\n" ans;
