const INF = 10**9
var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line) {
    lines.push(line);
});
reader.on('close', function () {
    const N = +lines[0];
    const h = lines[1].split(" ").map(x => +x);
    let dp = [];
    for (let i= 0; i < N; i++) {
        dp.push(INF);
    }
    dp[0] = 0;

    for (let i=1; i < h.length; i++) {
        dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(h[i - 1] - h[i]));
        if (i > 1) {
            dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(h[i - 2] - h[i]));
        }
    }
    console.log(dp[N - 1])
});