[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let hs = reads int |> List.toArray

    let dp = Array.create n 0
    for i = 1 to n - 1 do
        if i - 2 < 0 then
            dp.[i] <- dp.[i-1] + abs (hs.[i] - hs.[i-1])
        else
            dp.[i] <- min
                (dp.[i-2] + abs (hs.[i] - hs.[i-2]))
                (dp.[i-1] + abs (hs.[i] - hs.[i-1]))

    printfn "%i" dp.[n-1]
    0