open Batteries
let n = read_int ()
let h = read_line () |> String.split_on_char ' ' |> List.map int_of_string |> Array.of_list

let rec loop i result =
  if i = n-1 then result else
  if i + 1 = n-1 then loop (i+1) (result + (abs @@ h.(i) - h.(i+1))) else
  min (loop (i+1) (result + (abs @@ h.(i) - h.(i+1)))) (loop (i+2) (result + (abs @@ h.(i) - h.(i+2))))


let _ = Printf.printf "%d\n" @@ loop 0 0
