#K78267. Calculate the Median

    ID: 35049 Type: Default 1000ms 256MiB

Calculate the Median

Calculate the Median

You are given a list of scores. Your task is to compute the median of this list. The median is defined as follows:

  • If the number of scores (N) is odd, the median is the middle element of the sorted sequence.
  • If (N) is even, the median is the average of the two middle elements.

Formally, let the sorted scores be (a_1, a_2, \ldots, a_N). Then the median is:

  • ( \text{median} = a_{\frac{N+1}{2}} ) if (N) is odd,
  • ( \text{median} = \frac{a_{\frac{N}{2}} + a_{\frac{N}{2}+1}}{2} ) if (N) is even.

Print the computed median as a floating point number with exactly one decimal place.

inputFormat

The input consists of two lines. The first line contains a single integer (N), the number of scores. The second line contains (N) space-separated integers representing the scores.

outputFormat

Output a single line containing the median value as a float with one decimal place.## sample

5
1 3 4 2 5
3.0

</p>