'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function getArray(str) {
    return str.split(' ').map(x => Number(x));
}

function getInt(str) {
    return Number(str);
}

function getStrArray(str) {
    return str.split(' ').map(x => x);
}
// ---------------------------------------



function main() {
    const len = getInt(readline());
    const a = getArray(readline());
    const dp = new Array(len);
    dp.fill(-1);
    dp[0] = 0;
    dp[1] = Math.abs(a[1] - a[0]);
    const x = getCost(len-1, a);
    console.log(dp[len-1]);


    function getCost(i) {
        if(a < 0) {
            return 0;
        }
        if (dp[i] !== -1) {
            return dp[i];
        }

        dp[i] = Math.min(
            getCost(i-1) + Math.abs(a[i] - a[i - 1]),
            getCost(i-2) + Math.abs(a[i] - a[i - 2]),
        );

        return dp[i];
    }
}