import kotlin.math.abs
import kotlin.math.min

fun main() {
  val n = readLine()!!.toInt()
  val h = readLine()!!.split(' ').map { it.toInt() }
  val dp = IntArray(n+1){1000000001}
  dp[0] = 0
  dp[1] = abs(h[0]-h[1])

  for(i in 2 until n){
    dp[i] = min(dp[i], min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2]+ abs(h[i]-h[i-2])))
  }
  println(dp[n-1])
}