~/algor $ cat problems/ochkoz-juftliklar-minimumi
Sum of pair minimums
Easy
1000 ms
128 MB
31%
$2n$ positive integers are given. Split them into $n$ pairs (each number belongs to exactly one pair). From each pair its smaller number is taken, and all of them are added up. Choose the split that makes this sum as large as possible and find the sum.
Input
The first line contains a positive integer $n$. The second line contains $2n$ space-separated positive integers $a_{i}$.
Output
One integer — the largest value of the sum of pair minimums.
Note
$1 \le n \le 5 * 10^{4}$
$1 \le a_{i} \le 10^{9}$
Examples
Input #1
3 4 1 6 3 2 5
Output #1
9
Input #2
1 7 7
Output #2
7