function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0],10);
  const hn = input[1].split(' ').map((n) => {
    return parseInt(n, 10);
  });
  const h_max = Math.pow(10,9);
  console.log(dp(N,hn,h_max));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function dp(N,hn,h_max) {
  const dp = [];
  dp[0] = 0;
  for (var i = 1; i < N; i++) {
    dp.push(h_max);
    if (i === 1) {
      dp[i] = Math.min(dp[i],dp[i-1] + Math.abs(hn[i-1] - hn[i]))
    } else {
      dp[i] = Math.min(dp[i],dp[i-1] + Math.abs(hn[i-1] - hn[i]),dp[i-2] + Math.abs(hn[i-2] - hn[i]))
    }
  }
  return dp[N-1];
}
