"use strict";

function main(input){
  const args = input.trim().split('\n');
  const n = parseInt(args[0],10);
  const h = args[1].split(' ').map(_=>parseInt(_,10));
  
  const dp = Array(n).fill(0); // i => i-stepでの最小コスト
  dp[1] = Math.abs(h[1] -h[0]);
  for(let i=2; i<n; i++){
    const cost1 = dp[i-1] + Math.abs(h[i] - h[i-1]);
    const cost2 = dp[i-2] + Math.abs(h[i] - h[i-2]);
    dp[i] = Math.min(cost1, cost2);
  }
  
  console.log(dp[n-1]);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  