def min(a,b); a < b ? a : b; end
N = gets.to_i
H = gets.split.map(&:to_i)
dp = Array.new(N, 0)
(1 ... N).each do |j|
  if j >= 2
    dp[j] = min(dp[j - 2] + (H[j - 2] - H[j]).abs, dp[j - 1] + (H[j - 1] - H[j]).abs) 
  else
    dp[j] = dp[j - 1] + (H[j - 1] - H[j]).abs
  end
end
puts dp[-1]