local n=io.read("n")
local h={}
for i=1,n do
    h[i]=io.read("n")
end

local INF=math.maxinteger
local dp={0,math.abs(h[2]-h[1])}
for i=3,n do
    dp[i]=INF
end
for i=3,n do
    dp[i]=math.min(dp[i],dp[i-1]+math.abs(h[i]-h[i-1]))
    dp[i]=math.min(dp[i],dp[i-2]+math.abs(h[i]-h[i-2]))
end
print(dp[n])