import           Control.Monad
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  h <- getIntVec n

  dp <- VM.new n
  VM.write dp 0 0
  VM.write dp 1 (abs (h V.! 0 - h V.! 1))
  forM_ [2..n-1] $ \i -> do
    c2 <- VM.read dp (i - 2)
    c1 <- VM.read dp (i - 1)
    let c2' = c2 + abs (h V.! i - h V.! (i - 2))
        c1' = c1 + abs (h V.! i - h V.! (i - 1))
    VM.write dp i (min c1' c2')

  ans <- VM.read dp (n-1)
  print ans