gets
hs = gets.strip.split(" ").map(&:to_i)

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

2.upto(hs.size - 1) do |i|
  a = dp[i - 2] + (hs[i - 2] - hs[i]).abs
  b = dp[i - 1] + (hs[i - 1] - hs[i]).abs

  dp[i] = [a, b].min
end

puts dp.last
