import kotlin.math.*

fun main() {
  val N = Integer.parseInt(readLine()!!)
  val h = readLine()!!.split(" ").map(Integer::parseInt)

  var dp = IntArray(N) { 0 }
  dp[0] = 0
  dp[1] = abs(h[0] - h[1])
  var n = 2

  while (true) {
    if (n == N) break
    val c1 = abs(h[n-1] - h[n]) + dp[n-1]
    val c2 = abs(h[n-2] - h[n]) + dp[n-2]
    dp[n] = min(c1, c2)
    n++
  }

  println(dp[N-1])
}
