
import java.util.*

// https://atcoder.jp/contests/dp/tasks/dp_a
fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val heights = IntArray(n)
    for(i in 0 until n){
        heights[i] = sc.nextInt()
    }

    val dp = IntArray(n)
    dp[1] = Math.abs(heights[0] - heights[1])
    for(i in 2 until n) {
        dp[i] = Math.min(dp[i-1] + Math.abs(heights[i] - heights[i-1]), dp[i-2] + Math.abs(heights[i] - heights[i-2]))
    }

    println(dp[n-1])


}

