var inputRaw = require('fs').readFileSync('/dev/stdin', 'utf8')
var rows = inputRaw.trim().split('\n');
var N = Number(rows[0]);
var h = rows[1].split(' ').map(Number);
var dp = Array(N).fill(0);

function solve() {
  for (var i = 0; i < N - 1; i++) {
    if (i <= 0) {
      dp[i + 2] = Math.abs(h[i] - h[i + 1]);
    } else {
      var a = dp[i + 1] + Math.abs(h[i] - h[i + 1]);
      var b = dp[i] + Math.abs(h[i - 1] - h[i + 1]);
      dp[i + 2] = Math.min(a, b);
    }
  }
  return dp[N];
}

console.log(solve());
