import Data.Graph.Inductive

main :: IO ()
main = do
  n <- readLn
  hs <- map read . words <$> getLine
  print $ solve n hs

solve :: Int -> [Int] -> Int
solve n hs = spLength 1 n gr
  where
    gr = mkGraph ns es :: Gr () Int
    ns = [ (i, ()) | i <- [1..n] ]
    es = [ (i, i+k, abs (h0-h1)) | k <- [1,2], (i,h0,h1) <- zip3 [1..] hs (drop k hs) ]