#C14523. Find the Median Age

    ID: 44182 Type: Default 1000ms 256MiB

Find the Median Age

Find the Median Age

Given a list of ages, your task is to determine the median age. The median is defined as follows:

  • If the number of ages, n, is odd, then the median is the element at position \(\frac{n-1}{2}\) after sorting.
  • If n is even, then the median is computed as \(\frac{a[\frac{n}{2}-1] + a[\frac{n}{2}]}{2}\). In this case, even if the result is an integer, it should be printed with a decimal point (for example, 38.0).

You are required to read the input from stdin and print the result to stdout.

inputFormat

The input consists of two lines:

  1. The first line contains an integer \(n\) (\(1 \leq n \leq 10^5\)), the number of ages.
  2. The second line contains \(n\) space-separated integers representing the ages. The ages can be negative, zero or positive.

outputFormat

Output a single number which is the median age. If the input length is even, output the result with one decimal point even if the result is a whole number.

## sample
5
42 21 34 75 16
34

</p>