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