#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD
#define MODSUB(SUB_X,SUB_Y)  ((SUB_X-SUB_Y)+MOD)%MOD
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD
#define LCM(LCM_X,LCM_Y) (LCM_X/__gcd(LCM_X,LCM_Y))*LCM_Y
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e5+500;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int arr[MAX],mp[MAX];
void solve(int a){
    for(int i=0;i<MAX;i++){
        if(i-a>0 && mp[i-a])
            mp[i]=1;
    }
    mp[a]=1;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,sum=0;
    cin>>n;
    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        solve(a);
        sum+=a;
    }
    int mx=INT_MAX;
    for(int i=0;i<MAX;i++){
        if(mp[i]){
            int x=sum-i;
            mx=min(mx,max(x,i));
        }
    }
    cout<<mx<<endl;


    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int T,n,ans=1e9;
bitset<100004>f;
int main(){
	cin>>n;
	f[0]=1;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		f|=f<<x;T+=x;
	}
	for(int i=0;i<=1e5;i++)if(f[i])ans=min(ans,max(i,T-i));
	cout<<ans;
}