'use strict'

const main = input => {
	const args = input.trim().split('\n')
	const n = parseInt(args[0], 10)
	const h = args[1].split(' ').map(Number)
	const dp = new Array(n)

	for (let i = 0; i < n; i++) {
		dp[i] = Infinity
	}

	dp[0] = 0

	for (let i = 1; i < n; i++) {
		dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]))
		if (i > 1) dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]))
	}

	console.log(dp[n - 1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
