'use strict'
function main(input) {
  const tmp = input.split('\n');
  const N = parseInt(tmp[0], 10);
  const h = tmp[1].split(' ').map((elem) => parseInt(elem, 10));

  let dp = new Array(N);
  dp.fill(Infinity);
  dp[0] = 0;
  for (let i = 1; i < N; i++) {
    dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
    if (i > 1) {
      dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
    }
  }

  console.log(dp[N - 1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));