ashiba_num = gets.to_i
ashiba_cost = gets.split(' ').map(&:to_i)

dP = []
dP[0] = 0
dP[1] = (ashiba_cost[1] - ashiba_cost[0]).abs

range = 2..ashiba_num - 1 
range.each do |move|
    comp1 = dP[move - 1] + (ashiba_cost[move] - ashiba_cost[move - 1]).abs
    comp2 = dP[move - 2] + (ashiba_cost[move] - ashiba_cost[move - 2]).abs

    comp1 >= comp2 ? dP[move] = comp2 : dP[move] = comp1

end

p dP.last