open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = 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_lst in
  let l = List.sort (fun x y -> compare (abs x) (abs y)) l in
  let a = List.filter (fun x -> x > 0) l in
  let b = List.filter (fun x -> x < 0) l in
  let c = List.filter (fun x -> x = 0) l in
  let lena = List.length a in
  let lenb = List.length b in
  let lenc = List.length c in
  let lenl = List.length l in

  let ans =
    if lenb > lenl / 2 then
      let c = List.nth b ((lenb - lenl/2)-1) in
      let e = List.map (fun x -> x - c) l in
      List.fold_left (fun x y -> x + (abs y)) 0 e

    else 
    if lena > lenl / 2 then
      let c = List.nth a ((lena - lenl/2)-1) in
      let e = List.map (fun x -> x - c) l in
      List.fold_left (fun x y -> x + (abs y)) 0 e

    else begin
      List.fold_left (fun x y -> x + (abs y)) 0 l
    end
  in

  Printf.printf "%d\n" ans;
