import Data.Array

main = do
    n <- readLn :: IO Int
    hs <- map read.words <$> getLine :: IO [Int]
    print $ answer n hs

answer n hs = dp ! 1 where
    dp = array (1,n) $ (n,0): (n-1, n#(n-1)):[ (now, move now) | now <- [1..n-2]]
    move now = min (dp!(now+1) + now#(now+1)) (dp!(now+2) + now#(now+2))
    a # b = abs $ (hs!!(a-1)) - (hs!!(b-1))