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

fun edpa() {
    val n = readLine()!!.toInt()
    val height = readLine()!!.split(" ").map { it.toLong() }

    val costsToReach = Array(height.size) { Long.MAX_VALUE }

    costsToReach[0] = 0
    costsToReach[1] = Math.abs(height[0] - height[1])

    for (i in 2 until height.size) {
        val oneStepCost = Math.abs(height[i] - height[i - 1])
        val twoStepCost = Math.abs(height[i] - height[i - 2])

        val oneStepTotalCost = oneStepCost + costsToReach[i - 1]
        val twoStepTotalCost = twoStepCost + costsToReach[i - 2]

        costsToReach[i] = Math.min(oneStepTotalCost, twoStepTotalCost)
    }

    println(costsToReach[n - 1])
}
