#C14505. Median of a List

    ID: 44162 Type: Default 1000ms 256MiB

Median of a List

Median of a List

You are given a list of integers. Your task is to compute the median of the list. The median is defined as the middle value of the sorted list. If the number of elements is odd, the median is simply the middle element. If the number of elements is even, the median is the average of the two middle numbers.

In mathematical terms, if the sorted list is (a_1, a_2, \dots, a_n), then the median is given by:
- For odd (n): (a_{\frac{n+1}{2}})
- For even (n): (\frac{a_{\frac{n}{2}}+a_{\frac{n}{2}+1}}{2})

In this problem, you are required to read from standard input and print the result to standard output.

inputFormat

Input is provided via standard input. The first line contains an integer (n), representing the number of elements in the list. The second line contains (n) space-separated integers.

outputFormat

Output the median value on a single line. If the median is an integer, output the integer value; if it is a fractional number, output the floating-point value.## sample

5
3 5 1 4 2
3

</p>