{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import Data.Char (isSpace)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C


type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

getIntVec :: Int -> IO (U.Vector Int)
getIntVec n = U.unfoldrN n parseInt <$> C.getLine

paran2 :: (Eq a, Num a) => (t, t, a -> t -> t -> t) -> a -> t
paran2 (c, d, f) = u
  where
    u 0 = c
    u 1 = d
    u n = f n (u (n-2)) (u (n-1))

---------------------------------------------------------

main :: IO ()
main = do
  !n <- readLn :: IO Int
  !hs <- getIntVec n
  print $ step hs (n-1)

step :: U.Vector Int -> Int -> Int
step vec = fst . paran2 (c, d, f)
  where
    c = (0, vec U.! 0)
    d = (abs (h1-h), h) where (h1, h) = (vec U.! 0, vec U.! 1)
    f !n (!c2, !h2) (!c1, !h1) = (min c2' c1', h)
      where
        h = vec U.! n
        (!c2', !c1') = (c2+abs(h2-h), c1+abs(h1-h))
