
import java.lang.Math.abs
import java.lang.Math.min
import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        if (n < 2 || n > 100000) {
            throw Exception("Unexpected input.")
        }
        val hs = IntArray(n)
        for (i in 0 until n) {
            hs[i] = sc.nextInt()
        }
        val c = calcMinCost3(hs)
        println(c)
    } catch (e: Exception) {
        println(e)
    }
}

fun calcMinCost3(hs: IntArray): Int {
    val cs = IntArray(hs.size)
    cs[0] = 0
    cs[1] = abs(hs[0] - hs[1])
    for (i in 2 until hs.size) {
        cs[i] = min(
                cs[i - 2] + abs(hs[i - 2] - hs[i]),
                cs[i - 1] + abs(hs[i - 1] - hs[i])
        )
    }
    return cs[hs.size - 1]
}
