n=tonumber(io.read())
str=io.read()
h={}
for w in string.gmatch(str,"[^ ]+")do
	table.insert(h,w)
end
memo={}
function cal(i)
	if(memo[i]~=nil) then
		return memo[i]
	end
	local way1=cal(i-1)+math.abs(h[i]-h[i-1])
	local way2=99999999
	if(i>2) then
		way2=cal(i-2)+math.abs(h[i]-h[i-2])
	end
	if(way1<way2) then
		memo[i]=way1
	else
		memo[i]=way2
	end
	return memo[i]
end
memo[1]=0
memo[2]=math.abs(h[2]-h[1])
print(math.floor(cal(n)))