#C6929. Median Finder
Median Finder
Median Finder
Given a list of integers, your task is to compute the median of the list. First, sort the list in non-decreasing order. If the list has ( n ) elements, the median is defined as follows:
- If ( n ) is odd, the median is the middle element, i.e. ( a_{\frac{n+1}{2}} ).
- If ( n ) is even, the median is the average of the two middle elements, i.e. ( \frac{a_{\frac{n}{2}} + a_{\frac{n}{2}+1}}{2} ).
Print the resulting median as a floating-point number. It is guaranteed that there is at least one integer in the input.
inputFormat
Input is provided via standard input. The first line contains a single integer ( n ), the number of elements. The second line contains ( n ) space-separated integers.
outputFormat
Output the median value as a floating-point number to standard output.## sample
5
3 5 1 2 4
3.0
</p>