#include <bits/stdc++.h>

using namespace std;

const long long N = 100 + 5, T = 1e5 + 5, INF = 1e18 + 5;

long long n, arr[N], ans = INF, sum;

bool knapsack[T];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    cin >> n;

    for(int i = 0; i < n; i++) cin >> arr[i];

    sum = accumulate(arr, arr + n, 0ll);

    knapsack[0] = true;

    for(int i = 0; i < n; i++){
        for(int j = T - 1; j >= arr[i]; j--){
            if(knapsack[j - arr[i]]) knapsack[j] = true;
        }
    }

    for(int i = 0; i <= sum; i++){
        if(knapsack[i]) ans = min(ans, max((long long)i, sum - i));
    }

    cout << ans;
}
#include<bits/stdc++.h>
using namespace std;

#define  all(x)        (x).begin(),(x).end()
#define  pb            push_back
#define  lb            lower_bound
#define  ub            upper_bound
#define  fi            first
#define  se            second
#define  pii           pair<int,int>
#define  fastIO        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define  mp            make_pair
#define endl '\n'
#define int long long

typedef double db;
typedef long long ll;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int dp[101][N];

bool go(int n, vector<int>& arr, int sum) {

	if (sum == 0) return true;
	if (n == 0) return false;

	int& ret = dp[n][sum];
	if (ret != -1) return ret;

	if (arr[n - 1] <= sum) {
		//either inc or exclude
		bool inc = go(n - 1, arr, sum - arr[n - 1]);
		bool exc = go(n - 1, arr, sum);
		return ret = (inc | exc);
	}
	else {
		return ret = go(n - 1, arr, sum);
	}
}

void solve() {

	int n; cin >> n;
	vector<int> arr(n);
	int sum = 0;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sum += arr[i];
	}

	memset(dp, -1, sizeof(dp));

	int reqd = sum / 2;

	int sum1 = -1, sum2 = -1;

	for (int i = reqd; i >= 0; i--) {

		bool cur = go(n, arr, i);
		if (cur == 1) {
			sum1 = i;
			break;
		}
	}

	sum2 = sum - sum1;
	cout << max(sum1, sum2);
}

signed main() {

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

	fastIO

	int t = 1;
	// cin >> t;

	for (int tt = 1; tt <= t; tt++) {
		solve();
	}
}