#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
constexpr ll MOD = 998244353;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
ostream &operator<<(ostream &o, const string &obj) {o << "\""; o << obj.c_str(); o << "\""; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif

template <typename... Ts>
std::istream& IN(Ts&... xs){ return (std::cin >> ... >> xs); }

#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)

#define Rrepr(i, a, b) for (int i = b; i >= a; i--)
#define Rrep(i, n) for (int i = n-1; i >= 0; i--)

bool dfs(ll p, vector<vector<ll>>& v,vector<ll>& fin_list, vector<ll>& cv,ll c, ll depth){
    bool closed = false;
    if(fin_list[p]){
        if(depth >= 3) return true;
        else           return false;
    }
    cv[p] = c;
    fin_list[p] = 1;
    rep(i, v[p].size()){
        if(v[p][i]){
            closed |= dfs(i, v, fin_list, cv, c, depth+1);
        }
    }
    return closed;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    IN(n);

    vector<ll> t(n);
    ll tm_sum = 0;

    rep(i,n){
        IN(t[i]);
        tm_sum += t[i];
    }

    vector<vector<ll>> dp(n+1,vector<ll>(tm_sum/2+1,0));
    
    rep(i,n){
        rep(j,tm_sum/2+1){
            if(j >= t[i]) dp[i+1][j] = max(dp[i][j-t[i]]+t[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    ll ans = tm_sum - dp[n][tm_sum/2];
    //print(dp)

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
#define int long long
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define pii pair<int,int> 
#define F first
#define S second
#define endl "\n"
#define vmin *min_element
#define vmax *max_element
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define mp make_pair
#define yy cout<<"YES"<<endl
#define nn cout<<"NO"<<endl
#define nores cout<<"-1"<<endl
#define vi vector<int> 
#define all(x)   x.begin(),x.end()
#define prec(x)  fixed<<setprecision(x)
#define ppb  pop_back
#define gcd(a,b) __gcd(a,b)
#define si set<int> 
#define maxh priority_queue<int> 
#define minh priority_queue<int,vector<int>,greater<int> > 


signed main(){
   Fastio ;
   
 //  int t ; cin>>t;
 // while(t--)
 // {
 
 int n; cin>>n;
 vi v(n);
 int s=0;
 for(int i=0;i<n;i++){
 
 cin>>v[i];
 s=s+v[i];
}
 
 bool dp[n+1][s+1];
 for(int i=0;i<=n;i++)
 {
 	for(int j=0;j<=s;j++)
 	{
 		if(i==0) dp[i][j]=false;
 		else if(j==0) dp[i][j]=true;
 		
	 }
 }
 dp[0][0]=true;
 for(int i=1;i<=n;i++)
 {
 	for(int j=1;j<=s;j++)
 	{
 		if(j>=v[i-1])
 		dp[i][j]=(dp[i-1][j-v[i-1]] or dp[i-1][j]);
 		else
 		dp[i][j]=dp[i-1][j];
	 }
 }
 int ans;
 if(s%2==0)
 {
 
 for(int j=s/2;j<=s;j++)
 {
 	if(dp[n][j])
 	{
 		ans=j;
 		break;
	 }
 }
}
else
{
for(int j=(s/2)+1;j<=s;j++)
 {
 	if(dp[n][j])
 	{
 		ans=j;
 		break;
	 }
 }	
	
	
}
 cout<<ans<<endl;
}
 
 
  
 