input: Write a function to optimize the given Python function `find_max_sum(arr)` to reduce its time complexity. The original function calculates the maximum sum of any two elements in an array using a nested loop, which has a time complexity of O(n^2). Improve this function to achieve a better time complexity. If the given array is empty, the function should return 0.
  assert find_max_sum([1, 4, 2, 8, 3]) == 11
  assert find_max_sum([5, 2, 7, 1, 3]) == 12
  assert find_max_sum([2, 2, 2, 2]) == 4
  assert find_max_sum([8]) == 0
  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