import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    auto dp = new long[](N);
    fill(dp, 1L << 59);
    dp[0] = 0;
    dp[1] = abs(A[1] - A[0]);

    foreach (i; 2..N) {
        dp[i] = min(dp[i-2] + abs(A[i] - A[i-2]), dp[i-1] + abs(A[i] - A[i-1]));
    }

    dp[N-1].writeln;
}
