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

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

    val inf = 10000000000;

    var dp = Array(n) { inf }
    dp[0] = 0

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

    println(dp.last())
}