cho.sh
Notes
Loading...

Statistics

Time limit

2s

Memory limit

256 MB

Problem

Processing integers is an important task in statistics. Given an odd number NNN of integers, compute the following four basic statistics.

  1. Arithmetic mean: the sum of the NNN numbers divided by NNN, rounded to the nearest integer
  2. Median: the middle value after sorting the NNN numbers in nondecreasing order
  3. Mode: the value that appears most often. If there is more than one, use the second smallest such value
  4. 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 NNN. (1≤N≤500 000)(1 \le N \le 500\,000)(1≤N≤500000)

NNN is odd. Each of the next NNN lines contains one integer. The absolute value of every integer is at most 4 0004\,0004000.

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.