object Main {

  import scala.io.StdIn

  def main(args: Array[String]): Unit = {
    val n = StdIn.readInt
    val hs = StdIn.readLine.split(" ").map(_.toInt)

    val dp = Array.fill(n)(0)
    for (i <- (0 until n).reverse) {
      i match {
        case _ if i == n-1 => ()
        case _ if i == n-2 => dp(i) = Math.abs(hs(i) - hs(i+1))
        case _ => dp(i) = Math.min(Math.abs(hs(i) - hs(i+1)) + dp(i+1), Math.abs(hs(i) - hs(i+2)) + dp(i+2))
      }
    }
    println(dp(0))
  }
}