N = gets.to_i
hs = gets.split.map(&:to_i)

costs = Array.new(N)
costs[0] = 0
costs[1] = (hs[0] - hs[1]).abs
(2...N).each do |i|
  costs[i] = [costs[i-2] + (hs[i-2] - hs[i]).abs, costs[i-1] + (hs[i-1] - hs[i]).abs].min
end
puts costs[N-1]