n = gets.chomp.to_i
hs = gets.split.map(&:to_i)
dp = [0, 0, (hs[1] - hs[0]).abs]
(3..n).each do |i|
  dp[i] = [dp[i - 1] + (hs[i - 1] - hs[i - 2]).abs, dp[i - 2] + (hs[i - 1] - hs[i - 3]).abs].min
end
puts dp[n]