#include <bits/stdc++.h>
using namespace std;
 
 
int N;
int sum;
int T[50];
 
bool dp[51][2501][2501];
int ans = 1e9;
void dfs(int k,int x1,int x2){
    int x3 = sum - x1 - x2;
 
    //cout << x1 << " " << x2 << " " << x3 << endl;
    ans = min(ans,max({x1,x2,x3}));
    if( k == N ) return;
     
    if( dp[k][x1][x2] ) return;
 
    dp[k][x1][x2] = true;
    dfs(k+1,x1+T[k],x2);
    dfs(k+1,x1,x2);
     
    dfs(k+1,x1,x2+T[k]);
 
 
}
 
int main(){
    cin >> N;
    for(int i = 0 ;i < N ; i++){
        cin >> T[i];
        sum += T[i];
    }
    dfs(0,0,0);
    cout << ans << endl;
 
}