N = gets.to_i
H = gets.split.map &:to_i

dp = Array.new(N, nil)
dp[0] = 0

N.times do |i|
    next if i >= N - 1
    cost = (H[i+1] - H[i]).abs + dp[i]
    dp[i+1] = cost if dp[i+1].nil? || cost < dp[i+1]

    next if i >= N - 2
    cost = (H[i+2] - H[i]).abs + dp[i]
    dp[i+2] = cost if dp[i+2].nil? || cost < dp[i+2]
end

p dp[-1]