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

inf = 10 ** 7
dp = Array.new(n, inf)
dp[0] = 0

n.times do |i|
    dp[i] = [dp[i], dp[i - 1] + (hs[i] - hs[i - 1]).abs].min

    if i >= 2
        dp[i] = [dp[i], dp[i - 2] + (hs[i] - hs[i - 2]).abs].min
    end
end

puts dp[n - 1]
