Java | JavaScript | TypeScript | C++ | C# | Kotlin | Go Solution.
The presented solution applies a frequency array instead of a Hash Map. The problem can be solved very efficiently with a frequency array due to the small input
The presented solution applies a frequency array instead of a Hash Map. The problem can be solved very efficiently with a frequency array due to the small input range, [-1000, 1000], as of March 2025.

```Java []
public class Solution {

    private static final int[] RANGE_OF_VALUES = {-1000, 1000};
    private static final int OFFSET_FOR_NEGATIVES = 1000;

    public int getLargestOutlier(int[] input) {
        int[] frequency = new int[1 + RANGE_OF_VALUES[1] + OFFSET_FOR_NEGATIVES];
        int totalSumValues = 0;
        for (int value : input) {
            ++frequency[value + OFFSET_FOR_NEGATIVES];
            totalSumValues += value;
        }
        return findMaxOutlier(totalSumValues, frequency);
    }

    private int findMaxOutlier(int totalSumValues, int[] frequency) {
        int maxOutlier = Integer.MIN_VALUE;
        for (int value = RANGE_OF_VALUES[1]; value >= RANGE_OF_VALUES[0]; --value) {
            if (frequency[value + OFFSET_FOR_NEGATIVES] == 0) {
                continue;
            }
            double candidate = ((double) totalSumValues - value) / 2;
            if (isValidCandidateForSpecialNumberThatIsNotOutlier(candidate, value, frequency)) {
                maxOutlier = value;
                break;
            }
        }
        return maxOutlier;
    }

    private boolean isValidCandidateForSpecialNumberThatIsNotOutlier(double candidate, int value, int[] frequency) {
        return candidate == (int) candidate
                && candidate >= RANGE_OF_VALUES[0]
                && candidate <= RANGE_OF_VALUES[1]
                && frequency[(int) candidate + OFFSET_FOR_NEGATIVES] > 0
                && (value != (int) candidate || frequency[value + OFFSET_FOR_NEGATIVES] > 1);
    }
}
```
```JavaScript []
/**
 * @param {number[]} input
 * @return {number}
 */
var getLargestOutlier = function (input) {
    this.RANGE_OF_VALUES = [-1000, 1000];
    this.OFFSET_FOR_NEGATIVES = 1000;

    const frequency = new Array(1 + this.RANGE_OF_VALUES[1] + this.OFFSET_FOR_NEGATIVES).fill(0);
    let totalSumValues = 0;
    for (let value of input) {
        ++frequency[value + this.OFFSET_FOR_NEGATIVES];
        totalSumValues += value;
    }
    return findMaxOutlier(totalSumValues, frequency);
};

/**
 * @param {number} totalSumValues
 * @param {number[]} frequency
 * @return {number}
 */
function findMaxOutlier(totalSumValues, frequency) {
    let maxOutlier = Number.MIN_SAFE_INTEGER;
    for (let value = this.RANGE_OF_VALUES[1]; value >= this.RANGE_OF_VALUES[0]; --value) {
        if (frequency[value + this.OFFSET_FOR_NEGATIVES] === 0) {
            continue;
        }
        const candidate = (totalSumValues - value) / 2;
        if (isValidCandidateForSpecialNumberThatIsNotOutlier(candidate, value, frequency)) {
            maxOutlier = value;
            break;
        }
    }
    return maxOutlier;
}

/**
 * @param {number} candidate
 * @param {number} value
 * @param {number[]} frequency
 * @return {boolean}
 */
function isValidCandidateForSpecialNumberThatIsNotOutlier(candidate, value, frequency) {
    return candidate === Math.floor(candidate)
            && candidate >= this.RANGE_OF_VALUES[0]
            && candidate <= this.RANGE_OF_VALUES[1]
            && frequency[candidate + this.OFFSET_FOR_NEGATIVES] > 0
            && (value !== candidate || frequency[value + this.OFFSET_FOR_NEGATIVES] > 1);
}
```
```TypeScript []
function getLargestOutlier(input: number[]): number {
    this.RANGE_OF_VALUES = [-1000, 1000];
    this.OFFSET_FOR_NEGATIVES = 1000;

    const frequency = new Array(1 + this.RANGE_OF_VALUES[1] + this.OFFSET_FOR_NEGATIVES).fill(0);
    let totalSumValues = 0;
    for (let value of input) {
        ++frequency[value + this.OFFSET_FOR_NEGATIVES];
        totalSumValues += value;
    }
    return findMaxOutlier(totalSumValues, frequency);
};

function findMaxOutlier(totalSumValues: number, frequency: number[]): number {
    let maxOutlier = Number.MIN_SAFE_INTEGER;
    for (let value = this.RANGE_OF_VALUES[1]; value >= this.RANGE_OF_VALUES[0]; --value) {
        if (frequency[value + this.OFFSET_FOR_NEGATIVES] === 0) {
            continue;
        }
        const candidate = (totalSumValues - value) / 2;
        if (isValidCandidateForSpecialNumberThatIsNotOutlier(candidate, value, frequency)) {
            maxOutlier = value;
            break;
        }
    }
    return maxOutlier;
}

function isValidCandidateForSpecialNumberThatIsNotOutlier(candidate: number, value: number, frequency: number[]): boolean {
    return candidate === Math.floor(candidate)
        && candidate >= this.RANGE_OF_VALUES[0]
        && candidate <= this.RANGE_OF_VALUES[1]
        && frequency[candidate + this.OFFSET_FOR_NEGATIVES] > 0
        && (value !== candidate || frequency[value + this.OFFSET_FOR_NEGATIVES] > 1);
}
```
```C++ []
#include <span>
#include <limits>
#include <vector>
using namespace std;

class Solution {

    static constexpr array<int, 2> RANGE_OF_VALUES = { -1000, 1000 };
    static const int OFFSET_FOR_NEGATIVES = 1000;

public:
    int getLargestOutlier(vector<int>& input) const {
        array<int, 1 + RANGE_OF_VALUES[1] + OFFSET_FOR_NEGATIVES> frequency{};
        int totalSumValues = 0;
        for (const auto& value : input) {
            ++frequency[value + OFFSET_FOR_NEGATIVES];
            totalSumValues += value;
        }
        return findMaxOutlier(totalSumValues, frequency);
    }

private:
    int findMaxOutlier(int totalSumValues, span<const int> frequency) const {
        int maxOutlier = numeric_limits<int>::min();
        for (int value = RANGE_OF_VALUES[1]; value >= RANGE_OF_VALUES[0]; --value) {
            if (frequency[value + OFFSET_FOR_NEGATIVES] == 0) {
                continue;
            }
            double candidate = (static_cast<double>(totalSumValues) - value) / 2;
            if (isValidCandidateForSpecialNumberThatIsNotOutlier(candidate, value, frequency)) {
                maxOutlier = value;
                break;
            }
        }
        return maxOutlier;
    }

    bool isValidCandidateForSpecialNumberThatIsNotOutlier(double candidate, int value, span<const int> frequency) const {
        return candidate == (int)candidate
                && candidate >= RANGE_OF_VALUES[0]
                && candidate <= RANGE_OF_VALUES[1]
                && frequency[(int)candidate + OFFSET_FOR_NEGATIVES] > 0
                && (value != (int)candidate || frequency[value + OFFSET_FOR_NEGATIVES] > 1);
    }
};
```
```C# []
using System;

public class Solution
{
    private static readonly int[] RANGE_OF_VALUES = { -1000, 1000 };
    private static readonly int OFFSET_FOR_NEGATIVES = 1000;

    public int GetLargestOutlier(int[] input)
    {
        int[] frequency = new int[1 + RANGE_OF_VALUES[1] + OFFSET_FOR_NEGATIVES];
        int totalSumValues = 0;
        foreach (int value in input)
        {
            ++frequency[value + OFFSET_FOR_NEGATIVES];
            totalSumValues += value;
        }
        return FindMaxOutlier(totalSumValues, frequency);
    }

    private int FindMaxOutlier(int totalSumValues, int[] frequency)
    {
        int maxOutlier = int.MinValue;
        for (int value = RANGE_OF_VALUES[1]; value >= RANGE_OF_VALUES[0]; --value)
        {
            if (frequency[value + OFFSET_FOR_NEGATIVES] == 0)
            {
                continue;
            }
            double candidate = ((double)totalSumValues - value) / 2;
            if (IsValidCandidateForSpecialNumberThatIsNotOutlier(candidate, value, frequency))
            {
                maxOutlier = value;
                break;
            }
        }
        return maxOutlier;
    }

    private bool IsValidCandidateForSpecialNumberThatIsNotOutlier(double candidate, int value, int[] frequency)
    {
        return candidate == (int)candidate
                && candidate >= RANGE_OF_VALUES[0]
                && candidate <= RANGE_OF_VALUES[1]
                && frequency[(int)candidate + OFFSET_FOR_NEGATIVES] > 0
                && (value != (int)candidate || frequency[value + OFFSET_FOR_NEGATIVES] > 1);
    }
}
```
```Kotlin []
import kotlin.math.floor

class Solution {

    private companion object {
        val RANGE_OF_VALUES = intArrayOf(-1000, 1000)
        const val OFFSET_FOR_NEGATIVES = 1000
    }

    fun getLargestOutlier(input: IntArray): Int {
        val frequency = IntArray(1 + RANGE_OF_VALUES[1] + OFFSET_FOR_NEGATIVES)
        var totalSumValues = 0
        for (value in input) {
            ++frequency[value + OFFSET_FOR_NEGATIVES]
            totalSumValues += value
        }
        return findMaxOutlier(totalSumValues, frequency)
    }

    private fun findMaxOutlier(totalSumValues: Int, frequency: IntArray): Int {
        var maxOutlier = Int.MIN_VALUE
        for (value in RANGE_OF_VALUES[1] downTo RANGE_OF_VALUES[0]) {
            if (frequency[value + OFFSET_FOR_NEGATIVES] == 0) {
                continue
            }
            val candidate: Double = (totalSumValues.toDouble() - value) / 2
            if (isValidCandidateForSpecialNumberThatIsNotOutlier(candidate, value, frequency)) {
                maxOutlier = value
                break
            }
        }
        return maxOutlier
    }

    private fun isValidCandidateForSpecialNumberThatIsNotOutlier(candidate: Double, value: Int, frequency: IntArray): Boolean {
        return candidate == floor(candidate)
                && candidate >= RANGE_OF_VALUES[0]
                && candidate <= RANGE_OF_VALUES[1]
                && frequency[candidate.toInt() + OFFSET_FOR_NEGATIVES] > 0
                && (value != candidate.toInt() || frequency[value + OFFSET_FOR_NEGATIVES] > 1)
    }
}
```
```Go []
package main
import "math"

var RANGE_OF_VALUES = [2]int{-1000, 1000}
const OFFSET_FOR_NEGATIVES = 1000

func getLargestOutlier(input []int) int {
    frequency := make([]int, 1 + RANGE_OF_VALUES[1] + OFFSET_FOR_NEGATIVES)
    var totalSumValues = 0
    for _, value := range input {
        frequency[value + OFFSET_FOR_NEGATIVES]++
        totalSumValues += value
    }
    return findMaxOutlier(totalSumValues, frequency)
}

func findMaxOutlier(totalSumValues int, frequency []int) int {
    var maxOutlier = math.MinInt
    for value := RANGE_OF_VALUES[1]; value >= RANGE_OF_VALUES[0]; value-- {
        if frequency[value + OFFSET_FOR_NEGATIVES] == 0 {
            continue
        }
        candidate := float64(totalSumValues - value) / 2
        if isValidCandidateForSpecialNumberThatIsNotOutlier(candidate, value, frequency) {
            maxOutlier = value
            break
        }
    }
    return maxOutlier
}

func isValidCandidateForSpecialNumberThatIsNotOutlier(candidate float64, value int, frequency []int) bool {
    return candidate == math.Floor(candidate) &&
        int(candidate) >= RANGE_OF_VALUES[0] &&
        int(candidate) <= RANGE_OF_VALUES[1] &&
        frequency[int(candidate) + OFFSET_FOR_NEGATIVES] > 0 &&
        (value != int(candidate) || frequency[value + OFFSET_FOR_NEGATIVES] > 1)
}
```
['C++', 'Java', 'Go', 'TypeScript', 'Kotlin', 'JavaScript', 'C#']