n = gets.to_i
@hs = gets.chomp.split.map(&:to_i)
@dp = Array.new(n,nil)
def rec n
  if @dp[n]
     return @dp[n]
  end
  res = 10**9

  if n == 0
    return 0
  else
    res = [res, rec(n-1) + (@hs[n] - @hs[n-1]).abs].min
    if n > 1
      res = [res , rec(n-2) + (@hs[n] - @hs[n-2]).abs].min
    end
  end
  @dp[n] = res
end
puts rec(n-1)