#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

bool dp[60][2510][2510];

int main(){
    int n; cin>>n;
    vector<int> t(n);
    for(int i=0; i<n; i++) cin>>t[i];

    dp[0][0][0] = true;
    for(int i=0; i<n; i++){
        for(int j=0; j<=2500; j++){
            for(int k=0; k<=2500; k++){
                if(!dp[i][j][k]) continue;

                if(j + t[i] <= 2500) dp[i + 1][j + t[i]][k] = dp[i][j][k];
                if(k + t[i] <= 2500) dp[i + 1][j][k + t[i]] = dp[i][j][k];
                dp[i + 1][j][k] = true;
            } 
        }
    }

    int ans = 1e9;
    for(int i=0; i<=2500; i++){
        for(int j=0; j<=2500; j++){
            if(dp[n][i][j]){
                ans = min(ans, max({i, j, accumulate(t.begin(), t.end(), 0) - i - j}));
            }
        }
    }

    cout << ans << endl;
}
