SAC '22 Code Challenge 4 P3 - Obligatory Math Problem
View as PDFSince Max loves setting lazy problems, he starts fiddling with an array of  numbers, 
, and finds a problem:
Given an array, minimize
, where
is the minimizing value and
denotes the absolute difference between
and
.
Can you solve this lazy problem?
Constraints
Subtask 1 [40%]
Subtask 2 [60%]
Input Specification
The first line will contain , the number of elements in the array.
The second line will contain  space-separated integers, the elements of the array, 
.
Output Specification
Output the  that minimizes the equation 
.
Note: If there are multiple solutions, any will be accepted.
Sample Input
6
-5 4 9 -3 2 20
Sample Output
4
Note that  and 
 would also be valid solutions.
Comments