fun main(args: Array<String>) {
    edpa()
}

fun edpa() {
    val n = readLine()!!.toInt()
    val heights = readLine()!!.split(' ').map { it.toInt() }

    val inf =Long.MAX_VALUE/100
    val dp = LongArray(n) { inf }
    dp[0] = 0

    for (i in 0 until n - 1) {
        if (i + 1 <= heights.lastIndex) dp[i + 1] = Math.min(dp[i + 1], dp[i] + Math.abs(heights[i] - heights[i + 1]))
        if (i + 2 <= heights.lastIndex) dp[i + 2] = Math.min(dp[i + 2], dp[i] + Math.abs(heights[i] - heights[i + 2]))
    }

    val answer = dp[n - 1]

    println(answer)
}
