import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*
a[i]: i番目を踏むときの最善

漸化式は
a[i + 1] = min(a[i - 1] + abs(h[i + 1] - h[i - 1]), a[i] + abs(h[i + 1] - h[i]))

*/

void main(){
	long n = read.to!long;
	long[] hs = readln.chomp.split.map!(to!long).array;
	
	long[] as = [0, abs(hs[1] - hs[0])];
	foreach(i; 2 .. n){
		as ~= min(as[i - 2] + abs(hs[i] - hs[i - 2]), as[i - 1] + abs(hs[i] - hs[i - 1]));
	}
	
	as[n - 1].writeln;
}
