#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>

using namespace std;
static const int INF = 1000000000;
static int dp[2][2501][2501];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	const int m = accumulate(a.begin(), a.end(), 0);
	for(int i = 0; i <= m; ++i){
		for(int j = 0; j <= m; ++j){ dp[0][i][j] = 0; }
	}
	dp[0][0][0] = 1;
	for(int i = 0, sum = 0; i < n; ++i){
		const int cur = i & 1, next = 1 - cur, ai = a[i];
		sum += ai;
		for(int j = 0; j <= sum; ++j){
			for(int k = 0; k <= sum; ++k){ dp[next][j][k] = 0; }
		}
		for(int j = 0; j <= sum; ++j){
			for(int k = j; k <= sum; ++k){
				if(dp[cur][j][k] == 0){ continue; }
				const int x = 0, y = j, z = k;
				{	// (x, y, z + ai)
					array<int, 3> w = { x, y, z + ai };
					sort(w.begin(), w.end());
					w[1] -= w[0]; w[2] -= w[0]; w[0] = 0;
					dp[next][w[1]][w[2]] = 1;
				}
				{	// (x, y + ai, z)
					array<int, 3> w = { x, y + ai, z };
					sort(w.begin(), w.end());
					w[1] -= w[0]; w[2] -= w[0]; w[0] = 0;
					dp[next][w[1]][w[2]] = 1;
				}
				{	// (x + ai, y, z)
					array<int, 3> w = { x + ai, y, z };
					sort(w.begin(), w.end());
					w[1] -= w[0]; w[2] -= w[0]; w[0] = 0;
					dp[next][w[1]][w[2]] = 1;
				}
			}
		}
	}
	int answer = INF;
	for(int i = 0; i <= m; ++i){
		for(int j = 0; j <= m; ++j){
			if(dp[n & 1][i][j]){
				const int y = i, z = j;
				answer = min(answer, (m - y - z) / 3 + z);
			}
		}
	}
	cout << answer << endl;
	return 0;
}