(* O(n) *)
let n = Scanf.scanf " %d" @@ (+) 0
let hs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let dp = Array.make n 0
let cost i j = abs @@ hs.(i) - hs.(j)
let _ =
  dp.(1) <- cost 0 1;
  for i = 2 to n - 1 do dp.(i) <- min (dp.(i - 1) + cost (i - 1) i) @@ dp.(i - 2) + cost (i - 2) i done;
  Printf.printf "%d\n" @@ dp.(n - 1)