let input_int_array n =
	Array.init n (fun _ -> Scanf.scanf "%d " (fun v -> v))
let get_int () = Scanf.scanf "%d " (fun v -> v)

let test a b =
  Array.fold_left (fun (u,i) v -> 
    (* Printf.printf "  %d::abs(%d-(%d+%d))=%d\n"
      i v b i (abs (v-(b+i)))
    ; *)
    (u + (abs (v - (b+i)))), i+1) (0,1) a
  |> fst

let () =
  let n = get_int ()
  in let a = input_int_array n
  in let l = a |> Array.to_list
  in let lmax = List.fold_left max min_int l
  in let v = ref lmax in let f = ref true
  in let la = ref max_int
  in while !f do
    let r = test a !v
    in
    (* Printf.printf "%d::%d\n" !v r; *)
    if r < !la then (
      la := r; v := !v - 1
    ) else (
      f := false
    )
  done;
  !la |> string_of_int |> print_endline