Solution is not easy but I tried to make it simple. Please upvote if you like the solution
IntuitionApproachComplexity

Time complexity:
O(n)


Space complexity:
O(n)

Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
O(n)

- Space complexity:
O(n)

# Code
```java []
class Solution {
    public int getLargestOutlier(int[] nums) {
       int totalSum = 0, maxElement = Integer.MIN_VALUE;

        // Calculate total sum and find the max element
        for (int num : nums) {
            totalSum += num;
            maxElement = Math.max(maxElement, num);
        }

        HashMap<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            map.put(num, map.getOrDefault(num, 0) + 1);
        }

        int outlier = Integer.MIN_VALUE;

        for (int num : nums) {
            int remainingSum = totalSum - num;

            if (remainingSum % 2 == 0) {
                int p = remainingSum / 2;
                if (map.containsKey(p)) {
                    if (p == num && map.get(p) < 2) {
                        continue;
                    }

                    outlier = Math.max(outlier, num);
                }
            }

        }

        return outlier;
    }
}
```
['Java']