function Main(input){
	input = input.split("\n");
	var arr = input[1].split(" ").map(Number);
	var dp = [0,Math.abs(arr[0]-arr[1])];
	for(var i=2;i<arr.length;i++){
		dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
	}
	console.log(dp[dp.length-1]);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());