'use strict'

function chmin(a,b){
	if(a < b) return a;
	return b;
}

function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0]);
	let h = temp[1].split(' ').map((v)=>parseInt(v));

	let step = new Array(n+10).fill(9999999);
	step[0]=0;
	for(let i=0;i<n;i++){
		step[i+1] = chmin(step[i+1],step[i] + Math.abs(h[i]-h[i+1]));
		step[i+2] = chmin(step[i+2],step[i] + Math.abs(h[i]-h[i+2]));
	}
	console.log(step[n-1]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
