import java.lang.Math.abs
import java.lang.Math.min


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }
    val dp = DP()
    println(dp.jump(h, 0))

}

class DP {
    val memo = mutableMapOf<Int, Int>()

    fun jump(h: List<Int>, now: Int): Int {
        val nr = memo[now]
        if (nr is Int) return nr

        if (now == h.size - 2) {
            val r = abs(h[now] - h[now + 1])
            memo[now] = r
            return r
        }
        if (now == h.size - 3) {
            val r = min(abs(h[now] - h[now + 1]) + abs(h[now + 1] - h[now + 2]), abs(h[now] - h[now + 2]))
            memo[now] = r
            return r
        }
        val r = min(abs(h[now] - h[now + 1]) + jump(h, now + 1), abs(h[now] - h[now + 2]) + jump(h, now + 2))
        memo[now] = r
        return r
    }
}
