n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
ans = []
ans[0] = 0
ans[1] = (h[1] - h[0]).abs
for i in (2...n) do
  ans[i] = [ans[i-1] + (h[i] - h[i-1]).abs, ans[i-2] + (h[i] - h[i-2]).abs].min
end
puts ans[n-1]
