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

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

(2...n).each do |i|
  cost1 = dp[i-1] + (hs[i] - hs[i-1]).abs
  cost2 = dp[i-2] + (hs[i] - hs[i-2]).abs
  dp[i] = [cost1, cost2].min
end

puts dp[n-1]
