import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    hs <- VU.fromList <$> getIntList
    dp <- VUM.replicate n 0
    VUM.write dp 0 0
    VUM.write dp 1 $ abs ((hs VU.! 1) - (hs VU.! 0))
    forM_ [2..n-1] $ \i -> do
        a <- VUM.read dp (i - 1)
        b <- VUM.read dp (i - 2)
        let da = abs $ (hs VU.! (i - 1)) - (hs VU.! i)
        let db = abs $ (hs VU.! (i - 2)) - (hs VU.! i)
        VUM.write dp i $ min (a + da) (b + db)
    ans <- VUM.read dp (n - 1)
    print ans