#include <bits/stdc++.h>
#define NIL (-1)
#define ll long long
using namespace std;
const double PI = acos(-1.0);

int main() {
	int N;
	cin >> N;

	bitset<100001> dp;
	dp[0] = 1;
	int tot = 0;
	for (int i = 0; i < N; i++) {
		int T;
		cin >> T;
		tot += T;
		dp |= dp << T;
	}
	//cout << dp << endl;

	//cout << tot << endl;
	int ans = tot;
	for (int i = 0; i < dp.size(); i++) if (dp[i]) ans = min(ans, max(i, (tot - i)));
	cout << ans << endl;

	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main() {
 
int n;
int sum=0;
cin>>n;
int a[n],b[n];
for (int i = 0; i <n; i++)
{
  cin>>a[i];
}
for (int i = 0; i <n; i++)
{
  cin>>b[i];
}
for (int i = 0; i <n; i++)
{
  if (a[0]<a[i])
  {
    a[0]=a[i];
  }
 
  if (b[0]>b[i])
  {
    b[0]=b[i];
  }
  
}
 
for (int i = a[0]; i <=b[0]; i++)
{
  sum++;
}
 
cout<<sum;
 
return 0;
 
}