import java.util.*

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    
    val arr = Array<Int>(n, { cin.nextInt() })

    val costs = Array<Int>(n, { 0 })

    for (i in 0..n-1) {
        if (i == 0) {
            continue
        } else if (i == 1) {
            costs[i] = Math.abs(arr[0] - arr[1])
        } else {
            costs[i] = Math.min(costs[i-1] + Math.abs(arr[i] - arr[i - 1]), costs[i-2] + Math.abs(arr[i] - arr[i-2]))
        }
    }
    println(costs[n-1])
}