import std.array;
import std.conv;
import std.math;
import std.algorithm;
import std.string;
import std.stdio;

void main() {
	int n = readln.chomp.to!int;
	auto steps = readln.chomp.split(' ').map!(to!int).array;

	auto dp = new int[n];
	dp[1] = abs(steps[0] - steps[1]);

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

	writeln(dp[n - 1]);
}
