Intuitive and simple java solution
IntuitionTotalSum = specialNumbersSum + 2nd last number + outlier;
we know -> 2nd last number = sum(specialNumbers)i.e. TotalSum = 2 * (2nd last number) + outli
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
TotalSum = specialNumbersSum + 2nd last number + outlier;
we know -> 2nd last number = sum(specialNumbers)

i.e. TotalSum = 2 * (2nd last number) + outlier;
or outlier = TotalSum - 2 * (2nd last number)

# Approach
<!-- Describe your approach to solving the problem. -->
We can find the total sum easy in O(N)

We don't know what is the 2nd last number and so we can try all the options and see if we can maximize the outlier with below formula.

Outlier = TotalSum - 2 * (nums[i])

Edge case note: Note while confirming the outlier in each iteration, we have to be mindful of 2 conditions
1. The identified outlier needs to be a part of nums. i.e. it should be an element of nums.
2. The outlier itself cannot also be the 2nd elemment. i.e. in case of dupes, have the same index.

So we use a count Map to ensure we have more than one if the Outlier is also equal to the sum(2nd element).

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N) for iterating over all the elemenets on nums to calculate the total.
Map add operations will be amortizied O(1) and so we will consider it O(1).i.e. O(N) * O(1) = O(N)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
we are using a countmap for all elements in nums. So worst case they are all unique and we store N elements - O(N)

O(N)


# Code
```java []
class Solution {
    
    public int getLargestOutlier(int[] nums) {

        int total = 0;
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for( int i = 0; i < nums.length; i++ ){
            total += nums[i];
            map.put(nums[i], map.getOrDefault(nums[i], 0) + 1);
        }

        int maxOutlier = Integer.MIN_VALUE;
        for( int i = 0; i < nums.length; i++ ){
            int sum = 2 * nums[i];
            int out = total - sum;
            if( map.containsKey(out) && ( nums[i] != out || map.get(out) > 1 ) )
                maxOutlier = Math.max(maxOutlier, out);
        }
        return maxOutlier;
    }
}
```
['Java']