function Main (input) {
  const tmp = input.split('\n');
  const N = parseInt(tmp[0], 10);
  const stones = tmp[1].split(' ').map((elem) => parseInt(elem, 10));
 
  let dp = new Array(N);
  dp.fill(Infinity);
  dp[0] = 0;
  for (let i = 0; i < stones.length; i++) {
    for(let j = i + 1; j <= i + 2; j++ ) {
      if (j < stones.length) {
        dp[j] = Math.min(dp[j], dp[i] + Math.abs(stones[i] - stones[j]));
      }
    }
  }
  console.log(dp[stones.length - 1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));