"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines[0] - 0;
    let H = 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(H[n] - H[n - 1]));
        if (n > 1)
        dp[n] = Math.min(dp[n], dp[n-2] + Math.abs(H[n] - H[n - 2]));
    }
    console.log(dp[N-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));