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 (GCC 5.4.1) (judge verdict: Accepted)

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007LL
#define STR_EQ(s1,s2)       strcmp(s1,s2)==0
#define rep(i,n) for(int i=0;i<(n);i++)
#define invrep(i,n) for(int i=(n-1);i>=0;i--)
//#define MOD 998244353LL
//#define MOD 1000000009LL
const long long INF = 1LL << 60;
typedef long long ll;
ll llabs(ll a){if(a<0)return -a;return a;}//abs
void swap(ll *a,ll *b){ll tmp=*a;*a=*b;*b=tmp;}//swap
int fact(int a){int r=1;for(int i = 1;i<=a;i++)r*=i;return r;}//factral
ll addm(ll a, ll b){ll x = (a%MOD+b%MOD)%MOD;if (x < 0) x+=MOD;return x;}//addmod,submod
ll mulm(ll a, ll b){return(a%MOD*b%MOD)%MOD;}//mulmod
ll lpow(ll x,ll n){ll ans = 1;while(n){if(n&1) ans*=x;x*=x;n>>=1;}return ans;} //power
ll powm(ll x,ll n){x%=MOD;ll ans = 1;while(n){if(n&1) ans=mulm(ans,x);x=mulm(x,x);n>>=1;}return ans;} //power mod
ll lgcd(ll a, ll b){if(a==b) return a;if(a<b) swap(&a,&b);if (b == 0) return a;return lgcd(b, a%b);}//gcd
ll llcm(ll a, ll b){return a*b/lgcd(a,b);};//lcm
ll legcd(ll a,ll b,ll *x,ll *y){if(b==0){*x=1;y=0;return a;}ll q = a/b;ll g = legcd(b,a-q*b,x,y);ll z = *x-q*(*y);*x=*y;*y=z;return g;}//extra_gdd
ll divm(ll a,ll b){ll x,y;a%=MOD;b%=MOD;legcd(b,MOD,&x,&y);x%=MOD;if(x<0) x+=MOD;return x;}//divmod_with_extra_gdd
ll permutation(ll n, ll m){if(n<m) return 0;if(n-m < m) m = n-m;int ans = 1;for(int i = 0;i<m;i++) ans*=(n-i);return ans;}//nPm
ll combination(ll n, ll m){return permutation(n,m)/m;}//nCm
int acmpinum(const void * left, const void * right){
	if (*(int *)left > *(int *)right) return 1;
	else if (*(int *)left < *(int *)right) return -1;
	else return 0;
}//qsort(int配列,配列の長さ,sizeof(int),acmpinum);
int dcmpinum(const void * left, const void * right){
	if (*(int *)left > *(int *)right) return -1;
	else if (*(int *)left < *(int *)right) return 1;
	else return 0;
}//qsort(int配列,配列の長さ,sizeof(int),dcmpinum);
int acmpllnum(const void * left, const void * right){
	if (*(ll *)left > *(ll *)right) return 1;
	else if (*(ll *)left < *(ll *)right) return -1;
	else return 0;
}//qsort(ll配列,配列の長さ,sizeof(ll),acmpllnum);
int dcmpllnum(const void * left, const void * right){
	if (*(ll *)left > *(ll *)right) return -1;
	else if (*(ll *)left < *(ll *)right) return 1;
	else return 0;
}//qsort(ll配列,配列の長さ,sizeof(ll),dcmpllnum);
int cmpchar(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;
    return strcmp( left_char, right_char );
}//qsort(文字列配列,1,文字列の長さ,cmpchar);

int main(){
    int N;
    scanf("%d",&N);
    int L[2*N];
  	int ans=0;
  	rep(i,2*N) scanf("%d",&L[i]);
  	qsort(L,2*N,sizeof(int),acmpinum);
  	for(int i = 0;i<2*N;i+=2) ans+=L[i];
    printf("%d\n",ans);
    return 0;
}