#C3396. Maximum Stability Value of Stone Sequence

    ID: 46818 Type: Default 1000ms 256MiB

Maximum Stability Value of Stone Sequence

Maximum Stability Value of Stone Sequence

In this problem, you are given an integer (M) representing the number of stones and a list of (M) integers denoting the weights of these stones. Your task is to determine the stability value defined as the median of the sorted weights.

If (M) is odd, the stability value is the middle element of the sorted list. If (M) is even, the stability value is defined as the average of the two middle elements. Formally, if the sorted weights are (w_1, w_2, \ldots, w_M), then the stability value (S) is given by:

[ S = \begin{cases} w_{\frac{M+1}{2}}, & \text{if } M \text{ is odd}; \ \frac{w_{\frac{M}{2}} + w_{\frac{M}{2} + 1}}{2}, & \text{if } M \text{ is even}. \end{cases} ]

The answer must be printed with exactly six decimal places.

inputFormat

The input is read from standard input (stdin) and contains two lines.

The first line contains a single integer (M) ((1 \leq M \leq 10^5)), representing the number of stones.

The second line contains (M) space-separated integers representing the weights of the stones.

outputFormat

Output the maximum possible stability value (the median) as a floating-point number with exactly six digits after the decimal point. The output should be written to standard output (stdout).## sample

6
3 1 4 1 5 9
3.500000

</p>