import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val h = readLine.split(" ").map(_.toInt)

  val dp = Array.fill[Int](n)(Int.MaxValue)
  dp(0) = 0
  dp(1) = math.abs(h(1) - h(0))
  for (i <- 2 to n - 1) {
    val d1 = dp(i - 1) + math.abs(h(i - 1) - h(i))
    val d2 = dp(i - 2) + math.abs(h(i - 2) - h(i))
    dp(i) = math.min(d1, d2)
  }

  println(dp(n - 1))
}
