program main
     implicit none
     integer n,i,sumv,b
     integer,allocatable,dimension(:)::a
     read(*,*)n
     allocate(a(n))
     read(*,*)a
     do i=1,n
          a(i)=a(i)-i
     enddo
     sumv=0
     b=nint(sum(a)/dble(n))
     do i=1,n
          sumv=sumv+abs(b-a(i))
     enddo
     write(*,*)sumv
     
end program main
