input: from typing import List
  
  def max_total_reward(rewardValues: List[int]) -> int:
      """
      You are given an integer array rewardValues of length n, representing the values of rewards.
  
      Initially, your total reward x is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:
  
      Choose an unmarked index i from the range [0, n - 1].
      If rewardValues[i] is greater than your current total reward x, then add rewardValues[i] to x (i.e., x = x + rewardValues[i]), and mark the index i.
  
      Return an integer denoting the maximum total reward you can collect by performing the operations optimally.
  
      Examples:
      >>> rewardValues = [1,1,3,3]
      4
      >>> rewardValues = [1,6,4,3,2]
      11
  
      Constraints:
      1 <= rewardValues.length <= 2000
      1 <= rewardValues[i] <= 2000
      """
  
output: 
      rewardValues.sort(reverse=True)
      x = 0
      for value in rewardValues:
          if value > x:
              x += value
      return x
  