      PROGRAM Frog1
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: h(:),dp(:)
      integer(16) :: i,jump1,jump2
      
      read*, n
      allocate( h(1:n) )
      read*, h(:)
      
      allocate( dp(1:n) )
      dp(:) = 10**5
      dp(1) = 0
      dp(2) = abs( h(2)-h(1) )
      
      do i = 3,n
        jump1 = dp(i-1) + abs( h(i)-h(i-1) )
        jump2 = dp(i-2) + abs( h(i)-h(i-2) )
        dp(i) = min( jump1,jump2 )
      end do
      
      print*,dp(n)
      
      
      
      
      END PROGRAM