n = gets.to_i
array = gets.split.map(&:to_i)
dp = Array.new(n,1.0/0)
dp[0] = 0
dp[1] = (array[0]-array[1]).abs
dp.each_index {|i|
  if i == 0 || i == 1
    next
  end
  dp[i] = [dp[i-1]+(array[i]-array[i-1]).abs,dp[i-2]+(array[i-2]-array[i]).abs].min
}
puts dp[-1]
