n = gets.to_i
h = gets.split.map(&:to_i)
h << 0
dp = Array.new(n + 1) { Float::INFINITY }
dp[0] = 0

0.upto(n - 2) do |i|
  dp[i + 1] = [dp[i] + (h[i] - h[i + 1]).abs, dp[i + 1]].min
  dp[i + 2] = [dp[i] + (h[i] - h[i + 2]).abs, dp[i + 2]].min
end

puts dp[n - 1]
