#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
typedef long long ll;
using namespace std;
using P=pair<int,int>;
vector<vector<bool>> dp(101,vector<bool>(100001,false));
int main()
{
    int n;
    cin>>n;
    vector<int> t(n);
    rep(i,n) cin>>t[i];
    int sum=0;
    rep(i,n) sum+=t[i];
    dp[0][0]=true;
    for(int i=0;i<n;i++){
        for(int j=0;j<=sum;j++){
            if(dp[i][j]){
            dp[i+1][j+t[i]]=true;
            dp[i+1][j]=true;
        }
        }
    }
    int ans=sum;
    for(int j=0;j<=sum;j++){
       if(dp[n][j]) ans=min(ans,max(j,sum-j));
    }
    cout<<ans<<endl;
    return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <functional> // for less 
#include <iostream> 
using namespace __gnu_pbds; 
using namespace std; 
#define int long long
#define mod 1000000007 
 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> 
    ordered_set; 
typedef tree<int, null_type, 
             less_equal<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_multiset;

int ans;
int gosolve(int p,vector<int> &v)
{
//cout<<p<<" p\n";
int ors=0;
int xors=0;
ors=v[0];
vector<int> d;
d.push_back(v[0]);
for(int i=1;i<v.size();i++)
{
if(p&1)
{//cout<<" a\n";
int f=d.back();
  f=f|v[i];
  d[d.size()-1]=f;
}
else
{d.push_back(v[i]);
//cout<<" b\n";
}
//cout<<i<<"  "<<d.size()<<"  pi\n";
p=p>>1;
}


for(auto i: d)
{//cout<<i<<"  ";
xors=(xors^i);}
//cout<<xors<<"  xors\n";
return xors;

}
void go(vector<int> &v)
{
ans=-1;

int d=v.size()-1;
int k=1;
for(int i=1;i<=d;i++)
k=k*2;
//cout<<k<<"  k\n";
for(int i=0;i<k;i++)
{

int f=gosolve(i,v);
if(i==0)
  ans=f;
else
ans=min(ans,f);

}


cout<<ans<<endl;
return;
}

void solve()
{//ans=INT_MAX;
int n;
cin>>n;
vector<int> v;
for(int i=0;i<n;i++)
{int d;
  cin>>d;
  v.push_back(d);
}
if(n==1)
  {cout<<v.back()<<endl;
return;}

go(v);

//cout<<ans<<endl;
return;

}






int32_t main() {
   
ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("inp.txt",  "r",  stdin);
    freopen("m3.txt", "w", stdout);
#endif

int t;
t=1;
for(int i=1;i<=t;i++)
{
  solve();
//cout<<endl;
}





    return (int)(0);
}