#include<bits/stdc++.h>
using namespace std;
int dp[101][1000004];
int solve(int a[],int n, int cursum, int sum)
{
    if(n==-1)
    {
        return abs(sum-cursum-cursum);
    }
    
    if(dp[n][cursum]!=-1)
    return dp[n][cursum];
    
    return  dp[n][cursum]=min(solve(a,n-1,cursum,sum),solve(a,n-1,cursum+a[n],sum));
}
int main()
{
    int n;
    cin>>n;
    int a[n],sum=0;
    for(int i=0;i<n;i++)
    { cin>>a[i]; sum+=a[i]; }
    
    if(n==1)
    {
        cout<<a[0];
    }
    else if(n==2)
    {
        cout<<max(a[0],a[1]);
    }
    else{
    memset(dp,-1,sizeof dp);
    int diff=solve(a,n-1,0,sum);
    cout<<(diff+sum)/2;
    }    
}
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
using pii = pair<int, int>;
template<typename T>
using Prior = std::priority_queue<T>;
template<typename T>
using prior = std::priority_queue<T, vector<T>, greater<T>>;

#define X first
#define Y second
#define eb emplace_back
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int getRand(int L, int R) {
    if (L > R) swap(L, R);
    return (int)(rng() % ((uint64_t)R - L + 1) + L);
}

template<typename T1, typename T2>
ostream& operator << (ostream &os, pair<T1, T2> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template<typename T>
ostream& operator << (ostream &os, vector<T> &vec) {
    for (int i = 0; i < vec.size(); ++i) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}

const int maxn = 100 + 5;
const int maxc = 1000 + 5;

bitset<maxn * maxc> dp;

void solve() {
    int N, sum = 0; cin >> N;
    
    dp[0] = 1;
    while (N--) {int tmp; cin >> tmp, sum += tmp, dp |= dp << tmp;}
    
    for (int i = sum/2; i >= 0; --i) {
        if (dp[i]) return cout << sum - i << "\n", void();
    }
}

int32_t main() {
    fastIO();
    
    int t = 1; // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
    
    return 0;
}