import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);


void main() {
    int n = read();
    int[] h = reads();

    auto dp = new int[n];
    dp[0] = 0; dp[1] = abs(h[1] - h[0]);
    foreach (i; 2..n)
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1]
                , abs(h[i] - h[i-2]) + dp[i-2]);
    writeln(dp[n-1]);
}
