"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const steps = arg[1].split(" ").map(n=>parseInt(n));
    
    const dp = [...Array(N)].fill(Infinity);
    
    dp[0] = 0;
    dp[1] = Math.abs(steps[1] - steps[0]);
    
    for(let i=2; i<N; i++) {
        let oneStep = dp[i-1] + Math.abs(steps[i] - steps[i-1]);  
        let twoStep = dp[i-2] + Math.abs(steps[i] - steps[i-2]);
        
        dp[i] = Math.min(oneStep, twoStep);
    }
    
    console.log(dp[N-1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));