input: def rearrange_array(arr):
      """
      Given a list of non-negative integers, return a new list that is sorted.
      If the sum (first element, last element) is odd, sort the list in ascending order;
      if the sum is even, sort it in descending order.
  
      Note:
      * Do not modify the original list.
  
      Examples:
      * rearrange_array([]) => []
      * rearrange_array([5]) => [5]
      * rearrange_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
      * rearrange_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
      """
output:     if not arr:
          return []
      
      total = arr[0] + arr[-1]
      
      if total % 2 == 0:
          return sorted(arr, reverse=True)
      else:
          return sorted(arr)