#include<bits/stdc++.h>
#define haiyaku ios::sync_with_stdio(false), cin.tie(NULL);
#define PB push_back
#define F first
#define S second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define int long long
//#define double long double
 
const int MINI = -2147483647;
const int MAXI = 2147483647;
const long long MAXLL = 9223372036854775807ll / 4;
const long long MINLL = -9223372036854775807ll / 4;
 
using namespace std;
 
using pii = pair<int, int>;
using pll = pair<long long, long long>;

bitset<50001> dp;

signed main () {
  ios::sync_with_stdio(false), cin.tie(NULL);

  int N; cin >> N;
  vector<int> t(N);
  for(int &X : t) cin >> X;

  dp[0] = true;
  int sum = accumulate(all(t), 0ll);
  for(int V : t) {
    for(int i = sum / 2; i >= V; i--) 
      if (dp[i - V]) dp[i] = true;
  } 

  for(int i = sum / 2; i >= 0; i--) {
    if (dp[i]) {
      cout << sum - i << '\n';
      return 0;
    }
  }

  return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define  lsb(x) ((x) & (-x))
#define  PI acos(-1)
#define  line cout << endl;
#define  getbit(n, i) (((n) & (1LL << (i))) != 0)
#define  resetbit(n, i) ((n) & (~(1LL << (i))))
#define  setbit(n, i) ((n) | (1LL << (i)))
#define  togglebit(n, i) ((n) ^ (1LL << (i)))
const ll mod = (ll) 1e9+7; 
using namespace std;




int32_t main() {
  IOS
  #ifdef gm
  freopen("int.txt", "r", stdin);
  #endif
 int  n;
 cin >> n;


int sum = 0;

bitset<100005 >dp;
dp[0] =1;

for(int i= 0;i<n;i++)
{

int f;
cin >> f;
sum += f;
dp |= dp << f;


}

int res= sum;

for(int i=0;i< sum+1 ;i++)
{
    if(dp[i])
      res = min(res, max(i, sum - i));

}

cout << res << endl;
 return 0;      
  }
  


