program Frog_1
    implicit none
    integer(4), parameter:: inf=2000000005
    integer(4):: n,i
    integer(4), allocatable:: h(:), dp(:)

    read*, n
    allocate(h(-1:n), dp(-1:n))

    h(-1:0) = 100000
    read*, h(1:n)
    dp(:) = inf
    dp(1) = 0

    do i=2,n
        dp(i) = min(dp(i-1) + abs(h(i)-h(i-1)), dp(i-2) + abs(h(i)-h(i-2)))
    end do

    print*, dp(n)


end program Frog_1