input: Write a function to improve the time complexity of the given function `find_max_sum(arr)`, which finds the maximum sum of any two distinct elements in the array. The function should return the maximum sum. If the array is empty, return 0.
  
  
  def find_max_sum(arr):
      if not arr:
          return 0
      max_sum = 0
      left = 0
      right = len(arr) - 1
      arr.sort()  # Sorting the array to bring the largest elements together
      while left < right:
          current_sum = arr[left] + arr[right]
          if current_sum > max_sum:
              max_sum = current_sum
          if arr[left] > arr[right]:
              right -= 1
          else:
              left += 1
      return max_sum
  
  assert find_max_sum([3, 4, 5, 1, 2]) == 9
  assert find_max_sum([3, 5, 10, 1, 2]) == 15
  assert find_max_sum([4, 3, 1, 2]) == 6
  assert find_max_sum([3, 5, 4, 1, 2]) == 8
  assert find_max_sum([]) == 0
  
output: def find_max_sum(arr):
      if not arr:
          return 0
      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:
              second_max = num
      return first_max + second_max