'use strict'
(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  const N=input.shift();
  const dp=[0,Math.abs(input[1]-input[0])];
  for(let i=0;i<N-2;i++){
    let c1=dp[i+1]+Math.abs(input[i+2]-input[i+1]);
    let c2=dp[i]+Math.abs(input[i+2]-input[i]);
    dp[i+2]=Math.min(c1,c2);
  }
  console.log(dp[N-1]);
})(require('fs').readFileSync('/dev/stdin','utf8'));