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 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 t1 = abs (lena - lenb + lenc) in
  let t2 = abs (lenb - lena + lenc) in

  let ans =
    if lena > lenb + lenc then begin
      let c = (List.nth a (List.length l / 2 - 1)) in
      let e = List.map (fun x -> x - c) l in
      List.fold_left (fun x y -> x + (abs y)) 0 e
    end
    else
    if lenb > lena + lenc then begin
      let c = (List.nth b (List.length l / 2 - 1)) in
      let e = List.map (fun x -> x - c) l in
      List.fold_left (fun x y -> x + (abs y)) 0 e
    end
    else begin
      List.fold_left (fun x y -> x + (abs y)) 0 l
    end
  in

  Printf.printf "%d\n" ans
