import io.StdIn._
import math._

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

  val dp = new Array[Long](n)
  dp(0) = 0
  dp(1) = abs(hs(0) - hs(1))

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

  println(dp.last)
}