#K34747. Calculate the Median of a Sorted Array
Calculate the Median of a Sorted Array
Calculate the Median of a Sorted Array
Given an integer \(n\) followed by \(n\) integers, compute the median of these numbers after sorting them in non-decreasing order.
The median is defined as follows:
- If \(n\) is odd, the median is the middle element of the sorted array, i.e. \(a_{(n+1)/2}\).
- If \(n\) is even, the median is the average of the two middle elements, i.e. \(\frac{a_{n/2} + a_{n/2+1}}{2}\).
Your task is to calculate and output the median as a floating point number.
inputFormat
The input is given via standard input (stdin) and consists of two lines:
- The first line contains an integer \(n\) denoting the number of elements.
- The second line contains \(n\) space-separated integers.
outputFormat
Output the median of the sorted array as a floating point number to standard output (stdout).
## sample5
3 1 2 5 4
3.0