#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
int main()
{
	int N;
	cin >> N;
	int T[N];
	rep(i, 0, N) cin >> T[i];
	int tot = accumulate(T, T + N, 0);

	bool dp[N + 1][900011];
	fill((int *)dp, (int *)dp + sizeof(dp) / sizeof(int), false);
	dp[0][0] = true;

	rep(i, 0, N)
	{
		rep(j, 0, 100011)
		{
			if (dp[i][j])
			{
				dp[i + 1][j] = true;
				dp[i + 1][j + T[i]] = true;
			}
		}
	}
	int minv = INT_MAX;
	rep(j, 0, 100011)
	{
		if (dp[N][j])
		{
			minv = min(minv, abs(tot - j * 2));
		}
	}
	/*
	vector<int> vec;
	vec.push_back(0);
	rep(i,0,N){
			int l = vec.size();
			rep(j,0,l){
	//		cout <<i << " a " <<  a << " T " << T[i] << endl;
			vec.push_back(vec[j]+T[i]);
		}
	}
	*/

	//for(auto a:vec){
	/*rep(i, 0, vec.size())
	{
		//		cout << minv << " tot " << tot << " a " << a << endl;
		minv = min(minv, abs(tot - vec[i] * 2));
	}
	*/
	cout << (tot + minv) / 2 << endl;
}

// fuml namshebaazi
#include <bits/stdc++.h>
#define endl "\n";
using namespace std;
typedef long long ll;
int dp[100005][105];
void solve()
{
	int n;cin>>n;
	vector<int> v(n);
	int sum=0;
	for(int i=0;i<n;i++) {
		cin>>v[i];
		sum+=v[i];
	}
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=n;i++) dp[0][i]=1;
	for(int i=1;i<=sum;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i>=v[j-1]) dp[i][j]=max(dp[i][j-1],dp[i-v[j-1]][j-1]);
			dp[i][j]=max(dp[i][j],dp[i][j-1]);
		}
	}
	int ans;
	for(int i=sum/2;i<=sum;i++)
	{
		if(dp[i][n]==1) 
		{
			ans=i;
			break;
		}
	}
	cout<<max(ans,sum-ans);
	cout<<endl;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;t=1;
    while(t--)
	{
		solve();
	}
	return 0;
}