#K3201. Median of a List

    ID: 24906 Type: Default 1000ms 256MiB

Median of a List

Median of a List

You are given a list of numbers. Your task is to calculate the median of the list. The median is defined as follows:

If the list contains an odd number of elements, the median is the middle number after sorting the list. If the list contains an even number of elements, the median is given by \(\frac{a_{\frac{n}{2}}+a_{\frac{n}{2}+1}}{2}\), where \(a_i\) denotes the \(i^\text{th}\) smallest number. If the list is empty, output None.

Note: The input should be read from standard input and the output should be written to standard output.

inputFormat

The first line of the input contains a single integer \(N\) representing the number of elements in the list. If \(N > 0\), the second line contains \(N\) space-separated numbers (each of which may be an integer or a floating-point number). If \(N = 0\), there will be no second line.

outputFormat

Output the median of the list. If the median is an integer, output it without a decimal point; otherwise, output the floating point value. If the list is empty, output None.

## sample
7
1 3 3 6 7 8 9
6