#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	int N, a[ 100 ];
	int b[ 100 ];
	int Max = -1;
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[ i ];

	memset(b, 0, sizeof(b));

	int sum[ 10 ];
	

	for (int i = 0; i < (int)pow(4.0, (double)N); i++)
	{
		memset(sum, 0, sizeof(sum));
		for (int j = 0; j < N; j++)
		{
			if (b[ j ] == 0)
				sum[ 0 ] += a[ j ];
			else if (b[ j ] == 1)
				sum[ 1 ] += a[ j ];
			else if (b[ j ] == 2)
				sum[ 2 ] += a[ j ];
		}

		if ((sum[ 0 ] == sum[ 1 ]) && (sum[ 1 ] == sum[ 2 ]))
		{
			//printf("%d\n", sum[ 0 ]);
			Max = max(Max, sum[ 0 ]);
			//return 0;
		}

		//for (int j = 0; j < N; j++)
		//	cout << b[ j ];
		//cout << endl;

		b[ 0 ]++;
		for (int j = 0; j < N; j++)
			if (b[ j ] > 3)
			{
				b[ j ] = 0;
				b[ j + 1 ]++;
			}
	}

	if (Max == -1)
		printf("0\n");
	else 
		printf("%d\n", Max);

	fclose(stdin);
	fclose(stdout);
	return 0;
/*
10 4 2 3 7 8 9 1 2 3 4
10 1 2 3 4 5 6 7 8 9 10
*/
}