#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using C = complex<double>;


int main() {
    ll N;
    cin >> N;
    vector<ll> T(N);
    ll sum = 0;
    rep(n, N) {
        cin >> T[n];
        sum += T[n];
    }
    //cout << "ok" << endl;
    ll half = (sum+1)/2;
    ll ans = 0;
    vector<vector<bool>> dp(N+1, vector<bool>(sum+1));
    dp[0][0] = true;
    rep(n, N) {
        ll t = T[n];
        rep(w, sum+1) {
            if (dp[n][w]) dp[n+1][w] = true;
            if (w-t>= 0 && dp[n][w-t]) dp[n+1][w] = true;
        }
    }
    //cout << "ok" << endl;
    for(ll w = half; w <= sum; w++) {
        if (dp[N][w]) {
            ans = w;
            break;
        }
    }
    cout << ans << endl;
}
#include<bits/stdc++.h>
#define ll long long
using namespace std;

void readFile(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


int sol(vector<int> arr, int n){
    int sum = 0;
    for(int  i = 0 ; i < n ; ++i){
        sum += arr[i];
    }
    bool dp[n + 1][sum + 1];

    for(int i = 0 ; i <= n ; ++i){
        dp[i][0] = true;
    }

    for(int i = 1 ; i <= sum ; ++i){
        dp[0][i] = false;
    }

    for(int i = 1 ; i <= n ; ++i){
        for(int j = 1 ; j <= sum ; ++j){
            dp[i][j] = dp[i - 1][j];
            if(arr[i - 1] <= j){
                dp[i][j] |= dp[i - 1][j - arr[i - 1]];
            }
        }
    }

    // int diff = INT_MAX;
    int mx = INT_MIN;

    for(int j = sum / 2 ; j >= 0 ; --j){
        if(dp[n][j] == true){
            // diff = sum - 2 * j;
            mx = max(sum - j, j);
            break;
        }
    }
    return mx;
}


int main(){
    readFile();
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    vector<int> t;
    for(int i = 0 ; i < n ; ++i){
        int val;
        cin >> val;
        t.push_back(val);
    }
    cout << sol(t, n) << '\n';

    return 0;
}