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

dp = Array.new(N)
dp[0] = 0
dp[1] = (hs[0] - hs[1]).abs

(2..N).each do |i|
  dp[i] = [(hs[i] - dp[i - 1]).abs, (hs[i] - dp[i - 2]).abs].min
end

puts dp.last



