input: def modify_array(arr):
      """
      Given a list of non-negative integers, return a new list created by sorting the original list.
      Sort the list in ascending order if the sum of the first and last elements is odd,
      or in descending order if the sum of these elements is even.
  
      Note:
      * Do not alter the input list.
  
      Examples:
      * modify_array([]) => []
      * modify_array([5]) => [5]
      * modify_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
      * modify_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
      """
output:     if len(arr) == 0:
          return []
      elif len(arr) == 1:
          return arr.copy()
      
      sum_first_last = arr[0] + arr[-1]
  
      if sum_first_last % 2 == 0:
          return sorted(arr, reverse=True)
      else:
          return sorted(arr)