Average and median

Consider a set S={x1,,xk}S = \{x_1, \dots, x_k\} of natural numbers (maybe with repetitions), with odd kk. The average of SS is defined as (1ikxi)/k(\sum_{1 \le i \le k} x_i)/k. The median of SS is defined as the element that is in the middle of the set after we sort it. For instance, for S={1,2,2,4,5}S = \{ 1, 2, 2, 4, 5 \}, the average is (1+2+2+4+5)/5=14/5=2.8(1 + 2 + 2 + 4 + 5)/5 = 14/5 = 2.8, and the median is 2.

You are given a set of nn natural numbers, with even nn. Remove exactly one element so as to maximize the absolute value of the difference between the average and the median.

Input

Input consists of several cases, each one with an even nn, followed by nn natural numbers between 0 and 10910^9. Assume 4n1054 \le n \le 10^5.

Output

Print the maxim possible difference between the average and the median, with two digits after the decimal point. To do so, include these two lines at the beginning of your main:

    cout.setf(ios::fixed);
    cout.precision(2);

The input cases do not have precision issues.

Problem information

Author: Félix Moreno

Generation: 2026-01-25T11:32:20.540Z

© Jutge.org, 2006–2026.
https://jutge.org