#!/bin/bash -e

read n
read -a r

for ((i=0;i<n;i++)); do r[i]=$((r[i]-i)); done
(( ${#r[@]} == 1 )) && echo ${r[0]} && exit

a=( $( echo ${r[@]} | tr " " "\n" | sort -n ) )
b=${a[$((n/2))]}

declare -i s=0
for ((i=0;i<n/2;i++)); do s+=$((b-a[i])); done
for ((i=n/2;i<n;i++)); do s+=$((a[i]-b)); done

echo $s