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

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "damage", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto h = aryread();
    auto dp = new long[](n + 5);
    dp[] = INF;
    dp[0] = 0;
    foreach (i; iota(n))
    {
        if (i + 1 < n)
            dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]), dp[i + 1]);
        if (i + 2 < n)
            dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 2]);
    }
    dp[n - 1].writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
