import kotlin.math.abs
import kotlin.math.min

fun main() {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }

    val dp = IntArray(n + 1) { 0 }
    dp[2] = abs(h[1] - h[0])

    for (i in 3..n) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i - 2]), dp[i - 2] + abs(h[i - 1] - h[i - 3]))
    }
    println(dp[n])
}