import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()

    fun abs(dp:Pair<Int,Int>,h:Int) = Math.abs(dp.second - h)

    val DP = Array(N){0 to 0}
    DP[0] = 0 to sc.nextInt()
    val h = sc.nextInt()
    DP[1] = abs(DP[0],h) to h
    for (i in 2 until N) {
        val h = sc.nextInt()
        val min = Math.min(DP[i-1].first+abs(DP[i-1], h), DP[i-2].first+abs(DP[i-2], h))
        DP[i] = min to h
    }
    //for ((n,h) in DP) print("$n ")
    println(DP[N-1].first)
}