N = gets.to_i
steps = gets.split.map(&:to_i)
dp = []
dp[0] = 0
dp[1] = (steps[0]-steps[1]).abs
pos = 2
while pos < N
    dp[pos] = [(steps[pos] - steps[pos-1]).abs + dp[pos -1], (steps[pos] - steps[pos-2]).abs  + dp[pos -2]].min
    pos+=1
end
puts dp[N-1]
