Problem:
Score : 200 points

Problem Statement

Snuke is having a barbeque party.

At the party, he will make N servings of Skewer Meal.

Example of a serving of Skewer Meal

He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.
Also, he has an infinite supply of ingredients.

To make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers.
Let the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.

What is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?

Constraints

1≦N≦100

1≦L_i≦100

For each i, L_i is an integer.

Input

The input is given from Standard Input in the following format:

N
L_1 L_2 ... L_{2N}

Output

Print the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.

Sample Input 1

2
1 3 1 2

Sample Output 1

3

If he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of 3.

Sample Input 2

5
100 1 2 3 14 15 58 58 58 29

Sample Output 2

135

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;

#define oo 0x3f3f3f3f
#define mp make_pair
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define FO(i,a,b) for (int i=(a);i<=(b);++i)
#define FD(i,a,b) for (int i=(a);i>=(b);--i)
#define FE(i,G,x) for(int i=(G).h[x];~i;i=(G).v[i].nxt)
typedef long long LL;
typedef pair<int, int> PII;

template <class T> inline bool chkmin(T& x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T& x, T y) { return x < y ? x = y, true : false; }

inline LL read(void) {
    LL x, f = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
    return x * f;
}

#define MO 1000000007
#define M 2000

int f[2 * M + 5][2 * M + 5], c[2 * M + 5][2 * M + 5];
LL fac[4 * M + 5], nfac[4 * M + 5];
int n, x, y, ans;

inline int C(int x, int y) { return fac[x] * nfac[y] % MO * nfac[x - y] % MO; }
inline LL ppow(LL a, LL b) {
    LL ret = 1;
    for (; b; b >>= 1) {
        if (b & 1) ret = ret * a % MO;
        a = a * a % MO;
    }
    return ret;
}

int main(void) {
    n = read();
    nfac[0] = fac[0] = 1;
    FO(i, 1, 8000) fac[i] = fac[i - 1] * i % MO;
    FO(i, 1, 8000) nfac[i] = ppow(fac[i], MO - 2);
    FO(i, 1, n) {
        x = read(); y = read();
        f[M - x][M - y]++; // f[-x][-y]++
        c[M + x][M + y]++;
        (ans += MO - C((x + y) * 2, y * 2)) %= MO;
    }
    FO(i, 0, 2 * M)FO(j, 0, 2 * M) {
        if (j && !i) f[i][j] = f[i][j - 1];
        if (i && !j) f[i][j] = f[i - 1][j];
        if (i && j) f[i][j] = ((LL)f[i][j] + f[i - 1][j] + f[i][j - 1]) % MO;
    }
    FO(i, 0, 2 * M)FO(j, 0, 2 * M) (ans += f[i][j] * c[i][j] % MO) %= MO;
    printf("%d\n", ans * 500000004ll % MO);
    return 0;
}