#agc012a. [agc012_a]AtCoder Group Contest
[agc012_a]AtCoder Group Contest
Problem Statement
There are participants in AtCoder Group Contest. The strength of the -th participant is represented by an integer . They will form 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 , , has a strength , and a team of three participants of strength , , has a strength .
Find the maximum possible sum of the strengths of teams.
Constraints
- are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2
5 2 8 5 1 5
Sample Output 1
10
The following is one formation of teams that maximizes the sum of the strengths of teams:
- Team : consists of the first, fourth and fifth participants.
- Team : consists of the second, third and sixth participants.
Sample Input 2
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
Sample Output 2
10000000000
The sum of the strengths can be quite large.