#!/bin/bash -e

read n
declare -ai a

a=( $( for ((i=1;i<=n;i++)); do read -d " " x; echo $((x-i)); done | sort -n ) )
#echo ${a[@]}
b=${a[$((n/2))]}
#echo b=$b

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