import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val h = readLine().split(" ").map(_.toInt)
  def solve() = {
    val dp = Array.fill(n)(0)
    for(i <- 1 until n) {
      if(i == 1) dp(i) = (h(i) - h(i-1)).abs
      else dp(i) = Math.min(dp(i-1) + (h(i) - h(i-1)).abs, dp(i-2) + (h(i) - h(i-2)).abs)
    }
    dp(n-1)
  }

  println(solve())

}

