input: Write a function to find the maximum sum of two distinct elements in an array with reduced time complexity. The function should take an array as input and return the maximum sum of any two distinct elements in the array. If the array is empty, it should return 0.
  
  def find_max_sum(arr):
      if not arr:
          return 0
      arr.sort()
      return arr[-1] + arr[-2]
  
  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 len(arr) < 2:
          return 0
      max1, max2 = float('-inf'), float('-inf')
      for num in arr:
          if num > max1:
              max2 = max1
              max1 = num
          elif num > max2:
              max2 = num
      return max1 + max2