program linear
  implicit none
  integer(8) :: n, i, ans, j, k, loc(1)
  integer(8),allocatable :: a(:),flag(:)
  logical,allocatable :: m(:)

  read *, n 
  allocate(a(n))
  allocate(flag(n))
  flag = 0
  read *, a 
  do i = 1, n
    a(i) = a(i) - i
  end do 
!  print *, a
  m = (flag == 0)
  do j = 1, n/2
!    if (minval(a, mask = m) > 0) then 
      loc = minloc(a,mask = m)
      flag(loc(1)) = 1
      a = a - minval(a,mask = m)
!    else
!      flag(minloc(a,mask = m)) = 1
!    end if
  end do 
!  print *, a
ans = 0
  do k = 1, n 
    ans = ans + a(k)
  end do 
  print '(i0)', ans
  stop
end program linear