Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/ochkoz-juftliklar-minimumi

Sum of pair minimums

Easy 1000 ms 128 MB 31%
Share

$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.

The numbers are split into pairs; the smaller number of each pair is highlighted and they are added up

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

Sign in to submit a solution

Signing up is free and takes a minute.