function Main(s) {
  var s = s.split("\n");
  var n = s[0]*1;
  var h = s[1].split(" ").map(e => e*1);
  var dp = new Array(n);
  dp[0] = 0;
  for(var i = 1; i < n; i++) {  
    if (i >= 2) {
      dp[i] = Math.min(dp[i - 1] + Math.abs(h[i - 1] - h[i]), dp[i - 2] + Math.abs(h[i - 2] - h[i]))
    } else {
      dp[i] = Math.abs(h[i - 1] - h[i]);
    }
  }
  console.log(dp[dp.length - 1]);
}

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