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<iostream>
#include<cstdio>
#include<cstring>
namespace WoZhenTaMaShiGeLaJi
{
	const int N=2050,M=200100,MOD=1000000007;
	template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
	template<typename T>inline void inc(T a,T &b){b=((b+a)%MOD+MOD)%MOD;}
	typedef long long ll;
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
	ll inv(ll x){return qpow(x,MOD-2);}
	ll t1[N*2][N*2],*t2[N*2],**f;
	ll fact[N*4];
	int A[M],B[M];
	int n,mx,my;
	ll ans;
	ll C(int a,int b){return fact[a]*inv(fact[b])%MOD*inv(fact[a-b])%MOD;}
	void initialize()
	{
		for(int i=0;i<N*2;i++)t2[i]=t1[i]+N;f=t2+N;
		fact[0]=1;for(int i=1;i<N*4;i++)fact[i]=fact[i-1]*i%MOD;
		
		scanf("%d",&n);
		mx=my=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",A+i,B+i);
			f[-A[i]][-B[i]]++;
			check_max(A[i],mx);
			check_max(B[i],my);
		}
	}
	void solve()
	{
		initialize();
		for(int i=-mx;i<=mx;i++)
			for(int j=-my;j<=my;j++)
			{
//				printf("f[%d][%d] = %lld\n",i,j,f[i][j]);
				inc(f[i][j],f[i+1][j]);
				inc(f[i][j],f[i][j+1]);
			}
		ans=0;
		for(int i=1;i<=n;i++)
			inc(f[A[i]][B[i]],ans);
		for(int i=1;i<=n;i++)
			inc(-C(A[i]+B[i]+A[i]+B[i],A[i]+A[i]),ans);
		ans=(ans*inv(2)%MOD+MOD)%MOD;
		printf("%lld\n",ans);
	}
}
int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	WoZhenTaMaShiGeLaJi::solve();
	return 0;
}