#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

bool dp[53][1000][1000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, sum = 0;
    cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        sum += T[i];
    }
    dp[0][0][0] = true;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 1000; j++) for (int k = 0; k < 1000; k++) {
            if (!dp[i][j][k]) continue;
            int nj = j+T[i], nk = k+T[i];
            if (nj < 1000) dp[i+1][nj][k] = true;
            if (nk < 1000) dp[i+1][j][nk] = true;
            dp[i+1][j][k] = true;
        }
    }
    int ans = 3000;
    for (int i = 0; i < 1000; i++) for (int j = 0; j < 1000; j++) {
        if (!dp[N][i][j]) continue;
        int maxi = max(i, j);
        maxi = max(maxi, sum-i-j);
        ans = min(ans, maxi);
    }
    cout << ans << endl;
    return 0;
}