'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n');
  const N = tmp[0]|0;
  const h = tmp[1].split(' ').map(v=>v|0);
  const dp = Array(N).fill(Infinity);
  dp[0] = 0;
  for ( let i = 0; i < N-1; i++ ) {
    const j1 = Math.abs( h[i] - h[i+1] ) + dp[i];
    if ( dp[i+1] > j1 ) dp[i+1] = j1
    if ( i+1 === N ) break;
    const j2 = Math.abs( h[i] - h[i+2] ) + dp[i];
    if ( dp[i+2] > j2 ) dp[i+2] = j2;
  }
  return dp[N-1].toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
