import scala.math.{abs, min}

object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val h = Array.fill(n)(sc.nextInt)
  val dp = Array.fill(n)(10000)
  dp(0) = 0
  dp(1) = abs(h(0) - h(1))
  for (i <- 2 until n) {
    val x = dp(i-2) + abs(h(i-2) - h(i))
    val y = dp(i-1) + abs(h(i-1) - h(i))
    dp(i) = min(x, y)
  }
  println(dp.last)
}