#!/bin/bash -e

read n
declare -ai a

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

declare -i s=0
for ((i=0;i<n;i++)); do
  x=$((a[i]-b))
  s+=$(( (x>=0)?x:-x ))
done

echo $s