function main(input){
  var line1 = input[1].split(' ');
  var arr = Array(line1.length);
  for (var i=0; i<line1.length; i++){
    var one, two;
    if (i-1 < 0) one = -1;
    else {
      var h1 = parseInt(line1[i-1]);
      var h2 = parseInt(line1[i]);
      one = Math.abs(h1-h2);
    }
    if (i-2 < 0) two = -1;
    else {
      var h1 = parseInt(line1[i-2]);
      var h2 = parseInt(line1[i]);
      two = Math.abs(h1-h2);
    }
    if (one < 0) two < 0 ? arr[i] = 0 : arr[i] = arr[i-2] + two;
    else if (two < 0) arr[i] = arr[i-1] + one;
    else arr[i] = Math.min(arr[i-2] + two, arr[i-1] + one);
  }

  console.log(arr[line1.length-1]);
}


var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});
