input: Write a function to improve the time complexity of the given Python program that finds the maximum sum of any two distinct elements in an array.
  def find_max_sum(arr):
      max_sum = 0
      left = 0
      right = len(arr) - 1
      while left < right:
          if arr[left] + arr[right] > max_sum:
              max_sum = arr[left] + arr[right]
          if arr[left] > arr[right]:
              right -= 1
          else:
              left += 1
      return max_sum
  assert find_max_sum([1, 2, 3, 4, 5])==9
  assert find_max_sum([10, 20, 30, 40, 50])==90
  assert find_max_sum([0, 100, 200, 300, 400])==700
  assert find_max_sum([5, 5, 5, 5, 5])==10
  assert find_max_sum([1, 1, 1, 1, 2])==3
output: def find_max_sum(arr):
      first_max = second_max = float('-inf')
      for num in arr:
          if num > first_max:
              second_max = first_max
              first_max = num
          elif num > second_max and num != first_max:
              second_max = num
      return first_max + second_max