#K34312. Max Pair Sum of Minimums

    ID: 25282 Type: Default 1000ms 256MiB

Max Pair Sum of Minimums

Max Pair Sum of Minimums

You are given an even number of participants, each with a certain skill level. Your task is to pair up the participants such that the sum of the minimum skill level in each pair is maximized.

Formally, let \(a_1, a_2, \dots, a_{2n}\) be the skill levels. You need to partition these into \(n\) pairs \((x_i, y_i)\) and compute the value

[ S = \sum_{i=1}^{n} \min(x_i,y_i) ]

Your goal is to maximize \(S\). It can be shown that sorting the list and pairing adjacent elements yields the maximum sum.

inputFormat

The input is read from standard input (stdin) and consists of two lines. The first line contains a single even integer \(n\) — the number of participants. The second line contains \(n\) space-separated integers representing the skill levels of the participants.

outputFormat

Output a single integer representing the maximum possible sum of the minimum values of each pair. The output should be written to standard output (stdout).

## sample
6
1 2 3 4 5 6
9