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 c a b =
	Array.fold_left (fun u v -> u + abs (v-b)) 0 a

let () =
	let n = get_int ()
	in let a = Array.mapi
		(fun i v -> v - i - 1)
		(input_int_array n)
	in let b =
		let b = Array.copy a
		in Array.sort Pervasives.compare b; b
	in
	(
		if n mod 2 = 1 then (
			c b b.(Array.length b / 2)
		) else (
			min
				(c b b.(Array.length b / 2))
				(c b b.(Array.length b / 2 - 1))
		)
	)
	|> string_of_int |> print_endline