private fun readInts() = readLine()!!.split(" ").map(String::toInt)

fun main(args: Array<out String>) {
    val (N) = readInts()
    val h = readInts()

    val costs = Array(N) { 0 }
    costs[0] = 0
    costs[1] = Math.abs(h[1] - h[0])

    (2 until N).forEach { index ->
        val height = h[index]
        val _1 = costs[index - 1] + Math.abs(height - h[index - 1])
        val _2 = costs[index - 2] + Math.abs(height - h[index - 2])

        costs[index] = setOf(_1, _2).min()!!
    }

    println(costs[N - 1]) // 0-indexed
}