import java.lang.Math.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toInt()}
    var prev = 0
    var prev2 = 1000000000
    var now = 0
    for(i in 1 until N) {
        now = min(prev + abs(a[i] - a[i-1]), if(i > 1)prev2 + abs(a[i] - a[i-2]) else prev2)
        prev2 = prev
        prev = now
    }
    println(now)
}
