import java.util.Scanner
import java.lang.Math.*

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n  = scn.nextInt()
	val hs = IntArray(n){scn.nextInt()}
	val arr = IntArray(n){-1}

	for (i in arr.indices){
		when(i){
			0 -> arr[0] = 0
			1 -> arr[1] = abs(hs[1] - hs[0])
			else -> arr[i] = min(arr[i-2]+abs(hs[i]-hs[i-2]), arr[i-1]+abs(hs[i]-hs[i-1]))
		}
	}
	println(arr.last())

}