integer N
integer,allocatable,dimension(:)::H
integer DP(10**5)
read*,N
allocate(H(N))
read*,H

DP(1)=0
DP(2)=abs(H(2)-H(1))
if(N==2)then
  print"(i0)",DP(N)
  STOP
endif
do i=3,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"(i0)",DP(N)
end