import scala.io.StdIn
import scala.math._

object Main {

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

    val rec = new Array[Int](n)
    rec(0) = 0
    rec(1) = abs(hs(1) - hs(0))
    for (i <- 2 until n) {
      rec(i) = min(rec(i - 1) + abs(hs(i) - hs(i - 1)), rec(i - 2) + abs(hs(i) - hs(i - 2)))
    }

    println(rec(n - 1))

  }
}