n = gets.to_i
h = gets.split.map &:to_i

cost = Array.new(n, 0)
cost[0] = 0

1.upto(n-1).each{|i|
    cost1 = cost2 = 1e8.to_i
    cost1 = (h[i] - h[i-1]).abs + cost[i-1] if i > 0
    cost2 = (h[i] - h[i-2]).abs + cost[i-2] if i > 1
    cost[i] = [cost1, cost2].min
}

puts cost.last
