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