import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val N = scn.nextInt()

    var list = arrayOfNulls<Int>(N+1)
    for(i in 1..N){
        list[i] = scn.nextInt()
    }

    var dp = arrayOfNulls<Int>(N+1)
    for(i in 1..N){
        dp[i] = 0
    }

    dp[2] = abs(list[2]!! - list[1]!!)
    for(i in 3..N){
        var j1 = abs(list[i]!! - list[i-1]!!) + dp[i-1]!!
        var j2 = abs(list[i]!! - list[i-2]!!) + dp[i-2]!!
        dp[i] = min(j1,j2)
    }

    println(dp[N])
}