fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val hs = readLine()!!.split(' ').map { it.toInt() }

    val dp = Array(n) { Int.MAX_VALUE }

    (0 until n).forEach {
        if (it == 0) {
            dp[it] = 0
            return@forEach
        }

        if (it == 1) {
            dp[it] = Math.abs(hs[it] - hs[it - 1])
            return@forEach
        }

        val a = dp[it - 1] + Math.abs(hs[it] - hs[it - 1])
        val b = dp[it - 2] + Math.abs(hs[it] - hs[it - 2])

        dp[it] = Math.min(a, b)
    }

    println(dp.last())
}