open System

let INF = 1000000000
let N =stdin.ReadLine()|>int
let h =stdin.ReadLine().Split()|>Array.map int
[<EntryPoint>]
let main argv =
    let dp = [|for i in [0..N-1] do yield INF|]
    dp.[0] <- 0
    dp.[1] <- abs (h.[0] - h.[1])
    for i in [2..N-1] do
        dp.[i] <- min (dp.[i-2] + abs (h.[i-2]-h.[i])) (dp.[i-1] + abs (h.[i-1] - h.[i]))
    printfn "%d" dp.[N-1]
    0