#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 2000+1;
const int MAXX = MAX * MAX / 64 + 10;

LL DP[2][MAXX];
int A[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)
    scanf("%d", A + i);
    int sum = 0;
    FOR(i, 0, n)
    sum += A[i];
    DP[0][0] = 1;
    int lim = sum / 64 + 3;
    int C = 0, N = 1;
    FOR(i, 0, n)
    {
        FOR(j, 0, lim)
        {
            DP[N][j] |= DP[C][j];
            int full = A[i] / 64;
            int part = A[i] % 64;
            int jj = j + full;
            LL res = DP[C][j] << part;
            LL res2 = DP[C][j] >> (64 - part);
            if (jj < lim)DP[N][jj] |= res2;
            if (jj + 1 < lim)DP[N][jj+1] |= res;
        }
        swap(C, N);
        FOR(i, 0, lim)
            DP[N][i] = 0;
    }

    FOR(i, (sum + 1) / 2, sum+1)
        if (DP[C][i / 64] & (1ULL << (i % 64)))
        {
            cout << i << endl;
            return 0;
        }
}