
import Data.Array (Array, listArray, (!))

dp f s e = result ! e where
  result = listArray (s,e) $ map nth [s..]
  nth i = f result i

minjumpcost n hs = dp f 1 n where
  f _ 1 = 0
  f _ 2 = abs $ (hs!1) - (hs!2)
  f t i =
    let jump1 = (t!(i-1)) + abs ((hs!i) - (hs!(i-1)))
        jump2 = (t!(i-2)) + abs ((hs!i) - (hs!(i-2)))
    in
      min jump1 jump2

main = do
  n <- read . head . words <$> getLine :: IO Int
  hs <- listArray (1,n) . map read . words <$> getLine :: IO (Array Int Int)
  print $ minjumpcost n hs
