#include <bits/stdc++.h>
using namespace std;
// vtqi6hy80o@email.edu.pl
#define rep(i, a, b) for(lli i = a; i < b; i++)
#define lli long long int
#define ld long double
#define all(v) v.begin(), v.end()
#define hell 1000000000000000
#define pb push_back
#define pf push_front
#define vi vector<lli>
#define vip vector<pair<lli, lli>>
#define F first
#define S second
#define pi 2*acos(0.0)
#define sz(s) s.size()
#define atmod (1000000000+7)
#define mod 998244353 
// auto _C=clock();
/*
lli n = 10000000;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<bool> p(n + 1, true);
void sieve()
{
    for (long long int i = 2; i * i <= n; i++)
    {
        if (p[i])
        {
            for (long long int j = i + i; j <= n; j = j + i)
            {
                p[j] = false;
            }
        }
    }
}
*/
/*
WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!
Falling down is an accident, Staying down is a choice.
*/
/*lli binpow(lli a, lli n,lli m)
{
    lli r = 1;
    a %=m ;
    while (n > 0)
    {
        if (n & 1)
        {
            r = (r * a)%m ;
        }
        a = (a * a)%m ;
        n = n / 2;
    }
    return r;
}*/
/*bool cmp(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.F<b.F) return 1;
    else if(a.F==b.F) return(a.S>b.S);
    else return 0;
}*/
/*lli WaysFromOnetoOther(lli start,lli end,lli k)
{
    lli res = 0;
    if(k==1)
    {
        return 1;
    }
    rep(i,0,4)
    {
        if(i!=end&&i!=start)
        {
            res+=WaysFromOnetoOther(i,end,k-1);
        }
    }
    return res;
}*/
/*lli npr(lli n,lli r)
{
    lli res = 1;
    rep(i,1,r+1)
    {
        res=res%atmod*(n-r+i)%atmod;
        res%=atmod;
        // res/=i;
    }
    return res;
}*/
void solve() 
{
    lli n;
    cin>>n;
    lli t[n];
    lli s = 0,sum=0;
    rep(i,0,n)cin>>t[i];
    rep(i,0,n)
    {
        s+=t[i];
    }
    sum = s;
    if(s%2==0)
    {
        s=s/2;
    }
    else
    {
        s++;
        s=s/2;
    }
    // cout<<s<<"\n";
    lli dp[s+1][n+1];
    rep(i,0,s+1)
    {
        dp[i][0] = 0;
    }
    rep(i,0,n+1)
    {
        dp[0][i] = 0;
    }
    rep(S,1,s+1)
    {
        rep(i,1,n+1)
        {
            if(t[i-1]<=S)
            {
                dp[S][i] = max(dp[S-t[i-1]][i-1]+t[i-1],dp[S][i-1]);
            }
            else
            {
                dp[S][i] = dp[S][i-1];
            }
        }
    }
    cout<< max(dp[s][n],sum-dp[s][n]);
    // rep(S,0,s+1)
    // {
    //     rep(i,0,n+1)
    //     {
    //         cout<<dp[S][i]<<" ";
    //     }
    //     cout<<endl;
    // }
}   
int main()  
{ 
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0); 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout); 
    // sieve();
    lli t = 1;  
    // cin >> t;
    rep(i,1,t+1)
    {
        // cout<<"Case"<<" "<<"#"<<i<<":"<<" ";
        solve();
    }
    // cerr<<"\n\n\nTime elapsed: ";
    // cout<<"\n"<<(double)(clock()-_C)*1000.0/CLOCKS_PER_SEC<<"ms\n";      
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
template<class T> void chmin(T& a, T b) {
   if (a > b) {
      a = b;
   }
}

int main(){
   ll N;
   cin >> N;
   vector<ll> T(N);
   for(int i = 0; i < N; i++){
      cin >> T.at(i);
   }
   sort(T.begin(), T.end());

   double full_time = 0;
   for(int i = 0; i < N; i++){
      full_time += T.at(i);
   }
   ll half_time = ceil(full_time/2);

   vector<vector<ll>> visit(N,vector<ll>(full_time+1,0));
   visit.at(0).at(0) = 1;
   visit.at(0).at(T.at(0)) = 1;

   for(int i=1; i<N; i++){
      for(int j=0; j <= full_time; j++){
         if(visit.at(i-1).at(j)>0){
            visit.at(i).at(j)=1;
            visit.at(i).at(j + T.at(i))=1;
         }
      }
   }


  for(int i=half_time; i<=full_time; i++){
    if(visit.at(N-1).at(i)>0){
      cout << i << endl;
      break;
    }
  }
}