#C9694. Find the Median of Numbers

    ID: 53815 Type: Default 1000ms 256MiB

Find the Median of Numbers

Find the Median of Numbers

You are given a list of numbers. The task is to compute the median of the list. If the list has an odd number of elements, the median is the middle element after sorting. If the list has an even number of elements, the median is defined as \(\frac{a_{n/2} + a_{(n/2)+1}}{2}\) (in 1-indexing) after sorting.

The input will consist of an integer that specifies the count of numbers followed by the list of numbers. Your program should output the median. Note that when the median is not an integer, it must be printed with one decimal place (e.g. 4.5 or 3.0). Otherwise, print it as an integer.

inputFormat

The first line contains a single integer \(n\) indicating the number of elements. The second line contains \(n\) space-separated integers.

outputFormat

Output a single line containing the median value. If the median is a non-integer, output it as a floating-point number with one decimal place; otherwise, output it as an integer.

## sample
6
4 9 5 1 3 6
4.5