#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int dp[101][int(1e5 + 5)];
int n, mx, a[101];

int solve(int pos, int sum)
{
	if (pos == n)
	{
		return max(sum, mx - sum);
	}

	if (dp[pos][sum] != -1)
		return dp[pos][sum];

	int ans = INT_MAX;

	ans = min(solve(pos + 1, sum), solve(pos + 1, sum + a[pos]));

	return dp[pos][sum] = ans;
}

int main()
{
	faster;

	mem(dp, -1);
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i], mx += a[i];

	cout << solve(0, 0) << endl;

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

int dp[2][200000],ara[1000];

int main()
{


        int n,a,sum=0,s,i;

        scanf("%d",&n);


        for(i=0;i<n;i++)
        {
            scanf("%d",&a);  sum=sum+a;  ara[i]=a;
        }

        int fr,sc,tr,ans=90000000;

        int idx,cap;

        for(idx=n;idx>=0;idx--)
        {
            fr=idx&1;  sc=(idx+1)&1;

            for(cap=0;cap<=sum;cap++)
            {

                if(idx==n)
                {
                    if(cap==0)dp[fr][cap]=1;
                    else{  dp[fr][cap]=0;  }
                }
                else
                {

                    int x=0,y=0,z;

                    x=dp[sc][cap];

                    if(cap-ara[idx]>=0)
                    {
                        y=dp[sc][cap-ara[idx]];
                    }

                    z=x|y;

                    dp[fr][cap]=z;
                }


                if(idx==0)
                {
                    if(dp[fr][cap]==1)
                    {
                        s=max(cap,sum-cap);

                        //cout<<"  "<<cap<<"   "<<sum-cap<<endl;

                        ans=min(ans,s);

                    }

                }

            }
        }


        printf("%d\n",ans);



















   return 0;


}

