import scala.collection.mutable.{Seq => MutableSeq}

object Main extends App {
  val N = io.StdIn.readInt()
  val H = io.StdIn.readLine().split(" ").map(_.toInt).toSeq
  val dp_Default = MutableSeq.fill(H.length)(Int.MaxValue)

  println(rec(N - 1, H, dp_Default))

  def rec(i: Int, H: Seq[Int], dp: MutableSeq[Int]): Int = {
    if (dp(i) < Int.MaxValue) dp(i)
    if (i == 0) return 0
    var res = Int.MaxValue
    res = chmin(res, rec(i - 1, H, dp) + Math.abs(H(i) - H(i - 1)))
    if (i > 1) res = chmin(res, rec(i - 2, H, dp) + Math.abs(H(i) - H(i - 2)))
    dp(i) = res
    res
  }

  def chmin(a: Int, b: Int) = {
    if (a > b) b else a
  }
}