atcoder#AGC053B. [AGC053B] Taking the middle

[AGC053B] Taking the middle

Score : 700700 points

Problem Statement

We have 2N2N cards, with ID numbers from 11 through 2N2N. Card ii has a value of ViV_i. Takahashi and Aoki will do the following procedure NN times so that each of them gets NN cards.

  • First, Takahashi chooses one card that is not yet chosen and gets it. Then, Aoki chooses the card whose ID number is the median of those of the cards not yet chosen and gets it.

Find the maximum possible sum of the values of cards Takahashi has in the end.

Constraints

  • 1N2×1051\leq N\leq 2\times 10^5
  • 0Vi1090\leq V_i\leq 10^9
  • ViV_i is an integer.

Input

Input is given from Standard Input in the following format:

NN

V1V_1 V2V_2 \cdots V2NV_{2N}

Output

Print the answer.

3
1 2 3 4 5 6
15

Takahashi can get Cards 44, 55, and 66 as follows:

  • First, Takahashi chooses Card 66, which makes Aoki choose Card 33.
  • Next, Takahashi chooses Card 55, which makes Aoki choose Card 22.
  • Lastly, Takahashi chooses Card 44, which makes Aoki choose Card 11.
4
1 4 5 8 7 6 3 2
20