#AGC012A. [AGC012A] AtCoder Group Contest

[AGC012A] AtCoder Group Contest

Score : 300300 points

Problem Statement

There are 3N3N participants in AtCoder Group Contest. The strength of the ii-th participant is represented by an integer aia_i. They will form NN teams, each consisting of three participants. No participant may belong to multiple teams.

The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 11, 55, 22 has a strength 22, and a team of three participants of strength 33, 22, 33 has a strength 33.

Find the maximum possible sum of the strengths of NN teams.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1ai1091 \leq a_i \leq 10^{9}
  • aia_i are integers.

Input

Input is given from Standard Input in the following format:

NN

a1a_1 a2a_2 ...... a3Na_{3N}

Output

Print the answer.

2
5 2 8 5 1 5
10

The following is one formation of teams that maximizes the sum of the strengths of teams:

  • Team 11: consists of the first, fourth and fifth participants.
  • Team 22: consists of the second, third and sixth participants.
10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
10000000000

The sum of the strengths can be quite large.