#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
using P = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vint;
const int INF=1001001001;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d ;
  cout << b-c << endl;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (n); i++)
using ll = long long;
using P = pair<ll, ll>;
template<class T> 
bool chmax(T &a, T b) {if (a < b) {a = b;return true;}else return false;}
template<class T> 
bool chmin(T &a, T b) {if (a > b) {a = b;return true;}else return false;}
// struct Edge { ll to; ll cost; Edge(ll t, ll c) { to = t; cost = c;} };
// using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<ll>>;
// priority_queue<P, vector<P>, greater<P>> q;

const int INF = (1 << 30) - 1;
const ll LINF = (1LL << 60) - 1;
const double PI = acos(-1);

ll n, A;
ll a[110];

// dpテーブル

bool dp[110][100100];

int main() {
    cin >> n;
    ll sum = 0;
    rep(i, n) {
        ll val; cin >> val;
        sum += val;
        a[i] = val;
    }

    memset(dp, 0, sizeof(dp));  // 一旦すべて false に
    dp[0][0] = true;  // dp[0][0] だけ true に

    rep(i, n) {
        rep(j, sum+1) {
            dp[i+1][j] |= dp[i][j];
            if (j >= a[i]) dp[i+1][j] |= dp[i][j-a[i]];
        }
    }
    ll cnt = 100100;
    for (ll ans = sum; ans >= 0; ans--) {

        if (dp[n][ans]) {
            ll big = max(ans, sum - ans);
            // cout << ans << " " << sum-ans << endl;
            cnt = min(cnt, big);
        }
    }
    cout << cnt << endl;
    return 0;

} 

//小数点の出力
//cout << fixed << std::setprecision(15) << ans << endl;