#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
bool f[20];
int l[20];
int N;
int H(int a, int b, int c)
{
	return (a ^ ( b << 3 ) ^ (c << 6)) % 1500;
}
bool FF[9000][1500];
int test(int a, int b, int c, int mask)
{
	//if ( FF[mask][H(a,b,c)] ) return 0;
	//FF[mask][H(a,b,c)] = true;
	if ((int)(a > 0)+ (int)(b > 0)+(int)(c > 0) >= 2)
	{
		if (a == b && b == c) return a;
		if (a == b && c > a) return 0;
		if (a == c && b > a) return 0;
		if (c == b && a > c) return 0;
//		if (a == b || b == c || a == c) return 0;
	}
	int mx = 0;
	for (int i = 0; i < N; i++)
		if (!f[i])
		{
			
			f[i] = true;
			if(a < b)
				if (a < c)
					mx = max(mx, test(a+l[i], b, c, mask + (1 << i)));
				else mx = max(mx, test(a, b, c+l[i], mask + (1 << i)));
			else
				if (b < c)
					mx = max(mx, test(a, b+l[i], c, mask + (1 << i)));
				else mx = max(mx, test(a, b, c+l[i], mask + (1 << i)));
			
			f[i] = false;
		}
	return mx;
}
int main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cin >> N;
	for (int i = 0; i  < N; i++)
		cin >> l[i];
	cout << test(0,0,0,0);
}