let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let a' = Array.init n (fun i -> a.(i) - (i+1)) in
  Array.sort (-) a';
  let m = a'.((n-1)/2) in
  Array.mapi (fun i e -> abs (e - (m + (i+1)))) a
  |> Array.fold_left (+) 0 |> Printf.printf "%d\n"