#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> T(N);
    rep(i, N) cin >> T[i];

    constexpr int Tmax = 1000;
    vv<bool> dp = vvec(N + 1, N * Tmax + 1, false);
    dp[0][0] = true;
    rep(i, N) {
        rep(t, 0, Tmax * i + 1) {
            if (dp[i][t]) {
                dp[i + 1][t] = true;
                dp[i + 1][t + T[i]] = true;
            }
        }
    }

    int tsum = accumulate(all(T), 0);

    int ans = INF;
    rep(t, N * Tmax + 1) {
        if (dp[N][t]) {
            ans = min(ans, max(t, tsum - t));
        }
    }
    write(ans);
}
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll ncr(ll n,ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++) 
	{
        for (j = 0; j <= min(i, k); j++) 
		{
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }
    return C[n][k];
}

ll power(ll x, unsigned long long int y)
{
    if(y == 0)
        return 1;
    ll p = power(x, y / 2) % mod;
    p = (p * p) % mod;
 
    return (y % 2 == 0) ? p : (x * p) % mod;
}

ll modInverse(ll a)
{
    ll g = gcd(a, mod);
    if (g != 1)
        return -1;
    else
    {
        // If a and m are relatively prime, then modulo
        // inverse is a^(m-2) mode m
        return power(a, mod - 2);
    }
}

ll findMin(ll arr[], ll n)
{
    // Calculate sum of all elements
    ll sum = 0;
    for (ll i = 0; i < n; i++)
        sum += arr[i];
 
    bool dp[n+1][sum+1];
 
   
    for (ll i = 0; i <= n; i++)
        dp[i][0] = true;
 
    for (ll i = 1; i <= sum; i++)
        dp[0][i] = false;
 
    for (ll i=1; i<=n; i++)
    {
        for (ll j=1; j<=sum; j++)
        {
    
            dp[i][j] = dp[i-1][j];
 
            if (arr[i-1] <= j)
                dp[i][j] |= dp[i-1][j-arr[i-1]];
        }
    }
  
    ll diff = INT_MAX;
   
    for (ll j=sum/2; j>=0; j--)
    {
        // Find the
        if (dp[n][j] == true)
        {
            return sum-j;
        }
    }
    return diff;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin>>n;
    ll t[101];
    for(ll i=0;i<n;i++)
    {
        cin>>t[i];
    }
    cout<<findMin(t,n)<<endl;
}