import io.StdIn._

object Main extends App {
  val n = readInt()
  val hs = readLine() split(' ') map(_.toLong)

  def abs(a: Long, b: Long): Long =
    (a-b).abs

  val dp = new Array[Long](n)(Long.MaxValue)
  dp(0) = 0
  dp(1) = abs(hs(0),hs(1))

  for (i <- 2 until n) {
    dp(i) = math.min(abs(hs(i),hs(i-1)+dp(i-1)), abs(hs(i),hs(i-2))+dp(i-2))
  }

  println(dp.last)
}