atcoder#ABC291B. [ABC291B] Trimmed Mean

[ABC291B] Trimmed Mean

Score : 200200 points

Problem Statement

Takahashi is participating in a gymnastic competition. In the competition, each of 5N5N judges grades Takahashi's performance, and his score is determined as follows:

  • Invalidate the grades given by the NN judges who gave the highest grades.
  • Invalidate the grades given by the NN judges who gave the lowest grades.
  • Takahashi's score is defined as the average of the remaining 3N3N judges' grades.

More formally, Takahashi's score is obtained by performing the following procedure on the multiset of the judges' grades SS (S=5N|S|=5N):

  • Repeat the following operation NN times: choose the maximum element (if there are multiple such elements, choose one of them) and remove it from SS.
  • Repeat the following operation NN times: choose the minimum element (if there are multiple such elements, choose one of them) and remove it from SS.
  • Takahashi's score is defined as the average of the 3N3N elements remaining in SS.

The ii-th (1i5N)(1\leq i\leq 5N) judge's grade for Takahashi's performance was XiX_i points. Find Takahashi's score.

Constraints

  • 1N1001\leq N\leq 100
  • 0Xi1000\leq X_i\leq 100
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN

X1X_1 X2X_2 \ldots X5NX_{5N}

Output

Print Takahashi's score. Your answer will be considered correct if the absolute or relative error from the true value is at most 10510^{-5}.

1
10 100 20 50 30
33.333333333333336

Since N=1N=1, the grade given by one judge who gave the highest grade, and one with the lowest, are invalidated. The 22-nd judge gave the highest grade (100100 points), which is invalidated. Additionally, the 11-st judge gave the lowest grade (1010 points), which is also invalidated. Thus, the average is 20+50+303=33.333\displaystyle\frac{20+50+30}{3}=33.333\cdots.

Note that the output will be considered correct if the absolute or relative error from the true value is at most 10510^{-5}.

2
3 3 3 4 5 6 7 8 99 100
5.500000000000000

Since N=2N=2, the grades given by the two judges who gave the highest grades, and two with the lowest, are invalidated. The 1010-th and 99-th judges gave the highest grades (100100 and 9999 points, respectively), which are invalidated. Three judges, the 11-st, 22-nd, and 33-rd, gave the lowest grade (33 points), so two of them are invalidated. Thus, the average is 3+4+5+6+7+86=5.5\displaystyle\frac{3+4+5+6+7+8}{6}=5.5.

Note that the choice of the two invalidated judges from the three with the lowest grades does not affect the answer.