#include<bits/stdc++.h>
using namespace std;

#define lln long long int
#define MOD  1000000007

vector<vector<int> > adj(20001);
int freq;

void dfs(int i, vector<int> & vis)
{
    freq=freq+1;
    vis[i]=1;
    for(auto child: adj[i])
    {
        if(vis[child]==false)
        {
            dfs(child,vis);
        }
    }
}
int main()
{

    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);

    
    int n;
    cin>>n;

    int i, t[n],sum=0,j;

    for(i=0;i<n;i++)
    {
        cin>>t[i];
        sum+=t[i];
    }
// the question is reduced to fact that we have to divide the array in 2 parts such 
// that difference of their sum is minimum

// each element can either go to first part or second part.
    int dp[sum+1];

    
    for(i=0;i<=sum;i++)
    dp[i]=0;

    dp[0]=1;
    
    for(i=0;i<n;i++)
    {
        for(j=sum;j>=t[i];j--)
        dp[j] = dp[j] | dp[j-t[i]] ;
    }
    int min=INT_MAX, ans=-1;
    for(i=0;i<=sum;i++)
    {
        if(dp[i]>0)
        {
            if(abs(2*i-sum)< min)
            {
                min=abs(2*i-sum);
                ans = max(i, sum-i);
            }
        }
    }

    cout<<ans<<endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
// Ref: https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define dump(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << "\n";}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << "\n";}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cerr << "\n"; for(const auto& v : vv){ view(v); } }
template<typename T> void dump_cout(const T& v) { for(long long i = 0; i < v.size(); i++) std::cout << v[i] << (i == v.size()-1 ? "\n" : " "); }

ll dp[110][100010];

void chmin(ll &a, ll b) {
    a = min(a, b);
}

void solve() {
    rep(i, 0, 110) rep(j, 0, 100010) dp[i][j] = 1e9;
    ll n;
    cin >> n;
    vector<ll> t(n);
    rep(i, 0, n) cin >> t[i];
    dp[0][0] = 0;
    rep(i, 0, n) {
        rep(j, 0, 100001) {
            chmin(dp[i+1][j], dp[i][j]+t[i]);
            if(j + t[i] <= 100001) chmin(dp[i+1][j+t[i]], dp[i][j]);
        }
    }
    ll ans = 1e9;
    rep(i, 0, 100001) chmin(ans, max(dp[n][i], i));
    cout << ans << endl;
}

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