import java.util.Scanner

import scala.math._

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val h = Array.fill(N)(sc.nextInt)

  val dp = Array.fill(N)(Int.MaxValue)

  dp(0) = 0
  for (i <- 1 until N) {
    val dp1 = dp(i - 1) + abs(h(i) - h(i - 1))
    val dp2 = if (i != 1) dp(i - 2) + abs(h(i) - h(i - 2)) else Int.MaxValue
    dp(i) = min(dp1, dp2)
  }
  println(dp.last)
}
