fun main(args: Array<String>) {

    val N = readLine()!!.toInt()

    var h = readLine()!!.split(" ").map{it.toInt()}
    var dp =  IntArray(N){0}


    dp[1] = Math.abs(h[1] - h[0])
    for(i in 2 until N){
        dp[i] = Math.min(dp[i-2] + Math.abs(h[i] - h[i-2]), dp[i-1] + Math.abs(h[i] - h[i-1]))
    }
    println(dp[N-1]);



}