Using Binary Search
Intuition\n Describe your first thoughts on how to solve this problem. \n    you have to choose two variables one Outlier, one is sum so you have to run two loo
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n    you have to choose two variables one Outlier, one is sum so you have to run two loops.But constraint won\'t let you do that.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSo you run the outer loop from n-1 to 0 and for inner loop you can apply binary search because the array can be sorted.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nNlogN\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int f(int sum,int outlier,int s,int e,vector<int>&nums){\n        while(s<=e){\n            int m=s+(e-s)/2;\n            if((sum-2*nums[m])==0) return m;\n            else if((sum-2*nums[m])>0) { s = m+1;}\n            else{ e=m-1;}\n        }\n        return -1;\n    }\n    int getLargestOutlier(vector<int>& nums) {\n        int n=nums.size();\n        int sum=accumulate(nums.begin(), nums.end(), 0);\n        sort(nums.begin(),nums.end());\n        for(int i=n-1;i>=0;i--){\n            int outlier=nums[i];\n            int sum1=sum-outlier;\n            if(i!=n-1){\n                int res2=f(sum1,outlier,i+1,n-1,nums);\n                if(res2!=-1) return nums[i];\n            }\n            int res=f(sum1,outlier,0,i-1,nums);\n            if(res!=-1) return nums[i];\n        }\n        return -1;\n    }\n};\n\n```
['Binary Search', 'C++']