import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed

main :: IO ()
main = do
  n <- readLn :: IO Int
  hs <- listArray (1,n) . map read . words <$> getLine :: IO (UArray Int Int)
  print $ solve hs n ! n

solve :: UArray Int Int -> Int -> UArray Int Int
solve hs n = runSTUArray $ do
  dp <- newArray (1,n) 0
  forM_ [1..n] $
    \x -> case x of
      1 -> writeArray dp 1 0
      2 -> writeArray dp 2 $ abs $ (hs!2) - (hs!1)
      _ -> do
        a <- liftM2 (+) (readArray dp (x-1)) (return . abs $ hs!x - hs!(x-1))
        b <- liftM2 (+) (readArray dp (x-2)) (return . abs $ hs!x - hs!(x-2))
        writeArray dp x $ min a b
  return dp