input: Write a Python function that takes a list of integers, representing reward values. The function should return the maximum total reward that can be collected by optimally performing the following operation any number of times: select an unmarked index whose reward value is greater than the current total reward and add that value to the total reward.
output: def max_reward(rewards):
      rewards.sort()
      total_reward = 0
      for reward in rewards:
          if reward > total_reward:
              total_reward += reward
      return total_reward