"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines[0] - 0;
    let Hs = lines[1].split(/\s/).map((v) => v - 0);

    let dp = new Array(N).fill(Number.MAX_SAFE_INTEGER);
    dp[0] = 0;
    for (let n = 1; n < N; n++) {
        dp[n] = Math.min(dp[n], dp[n-1] + Math.abs(Hs[n - 1] - Hs[n]));
        if (n > 1)
        dp[n] = Math.min(dp[n], dp[n-2] + Math.abs(Hs[n - 2] - Hs[n]));
    }

    console.log(dp[N-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));