#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i< t ;i++)

#define SZ(x) (int)x.size()
using LL = long long; using ll = LL;
const int INF = 1e9; const LL LINF = 1e18;

#define MAXT 1005
ll N;
vector<int> T;
bool memo[55][MAXT][MAXT];

void dfs(int n, int x, int y,ll sum) {
	if (memo[n][x][y]) return;
	memo[n][x][y] = true;
	if (n == N) return;
	if (x + T[n] < MAXT) dfs(n + 1, x + T[n], y,sum + T[n]);
	if (y + T[n] < MAXT) dfs(n + 1, x, y + T[n],sum + T[n]);
	if (sum - x - y + T[n] < MAXT) dfs(n + 1, x, y, sum + T[n]);
}

void solve() {
	cin >> N;
	T.resize(N);
	for (auto& in : T) { cin >> in; }
	sort(T.begin(), T.end());
	reverse(T.begin(), T.end());
	dfs(0, 0, 0, 0);
	int sum = accumulate(T.begin(), T.end(), 0);

	ll ans = LINF;
	for (int i = 0; i < MAXT; i++) {
		for (int j = 0; j < MAXT; j++) {
			if (memo[N][i][j] == false) continue;
			ll t = -1;
			t = max({ i,j,sum - i - j });
			ans = min(ans, t);
		}
	}
	cout << ans << endl;
}


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}


