How to solve HHMGN of Loc june 2017? I am unable to find its Editorial.

The solution is simple. First sort all the numbers and then calculate the prefix sum array for this sorted array. Next for each value (lets call is * N*) check whether sum of all values less than

*+ sum of all values greater than*

**N***converted to*

**N***is equal to*

**N***and the first value with which the sum equals to*

**S***is the answer.*

**S**Why does this solution give the correct answer?

Thatâ€™s because we are basically trying each and every number (lets call it * M*) and checking whether the sum of all the numbers greater than

*converted to*

**M***+ sum of all numbers less than*

**M***equals*

**M***.*

**S**```
[1]
[1]: https://www.codechef.com/viewsolution/14375184
```

I also do this question as you said but got only 30 points.

Here is my solution.

https://www.codechef.com/viewsolution/14375033