input: 
  def gini(x):
      """Calculate Gini Coefficient of a given dataset.
      >>> gini([2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21])
      0.605
      """
  
output:     
      n = len(x)
      if n == 0:
          return 0
      total_sum = sum(x)
      squared_sum = sum(num**2 for num in x)
      gini_coef = 1 - (squared_sum / (total_sum**2))
      return round(gini_coef * n / (n - 1), 3)
  