#C6955. Median Calculation

    ID: 50772 Type: Default 1000ms 256MiB

Median Calculation

Median Calculation

Given a series of numbers, your task is to calculate the median value. The median is defined as the middle number when the numbers are sorted in increasing order. For an odd number of elements, the median is the middle element. For an even number of elements, the median is computed as \(\frac{a+b}{2}\), where \(a\) and \(b\) are the two middle numbers. If no numbers are provided, output None.

inputFormat

The input consists of two lines. The first line contains a single integer \( n \) representing the number of elements. The second line contains \( n \) space-separated numbers. If \( n \) is 0, the second line will be empty.

outputFormat

Output the median of the given numbers. If no numbers are provided, output None. For cases where the median is an integer, output it as an integer; otherwise, output the decimal value.

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