program main
     implicit none
     integer n,i,sumv1,sumv2,b1,b2
     integer,allocatable,dimension(:)::a
     read(*,*)n
     allocate(a(n))
     read(*,*)a
     do i=1,n
          a(i)=a(i)-i
     enddo
     sumv1=0;sumv2=0
     b1=sum(a)/n
     b2=b1-1
     do i=1,n
          sumv1=sumv1+abs(b1-a(i))
          sumv2=sumv2+abs(b2-a(i))
     enddo
     write(*,*)min(sumv1,sumv2)
     
end program main
