All problems

The Robust Middle

easyPythonStatistics

Alderway Recruitment publishes a pay guide for every job title it places. A handful of very large packages at the top would drag an ordinary average upwards and make the guide misleading, so the guide quotes the median instead — the salary that sits in the middle once every salary is lined up in order. Salaries reach the script in the order they were collected, which is no order at all.

Task: Print the median salary.

Input

The first line holds one integer n, how many salaries follow. Each of the next n lines holds one salary as a plain number. The salaries are unsorted. When n is even there is no single middle salary; the median is then the value halfway between the two middle ones.

Output

One line holding the median, written with exactly one digit after the decimal point.

Example:

Input:
4
10
20
30
100

Output:
25.0

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…