Statistics
InterviewTime limit2sMemory limit256 MB
Given N odd integers, compute and print the rounded mean, median, mode (second smallest if tied), and range.
Problem
Processing integers is an important task in statistics. Given an odd number of integers, compute the following four basic statistics.
- Arithmetic mean: the sum of the numbers divided by , rounded to the nearest integer
- Median: the middle value after sorting the numbers in nondecreasing order
- Mode: the value that appears most often. If there is more than one, use the second smallest such value
- Range: the difference between the maximum and minimum values
Write a program that prints these four values for the given numbers, in order.
Input
The first line contains the number of values .
is odd. Each of the next lines contains one integer. The absolute value of every integer is at most .
Output
On the first line, print the arithmetic mean, rounded to the nearest integer.
On the second line, print the median.
On the third line, print the mode. If there are multiple modes, print the second smallest one.
On the fourth line, print the range.