#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
int total = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
total += a[i];
}
int half = total / 2;
sort(a.begin(), a.end());
bool dp[total + 1];
memset(dp, false, sizeof(dp));
dp[0] = true;
int ans = 0;
for (int i = n - 1; i >= 0; i--) {
int x = a[i];
for (int j = total; j >= x; j--) {
if (dp[j - x]) {
dp[j] = true;
}
}
int L = half + 1;
int R = half + x;
if (R > total) R = total;
for (int j = R; j >= L; j--) {
if (dp[j]) {
ans = max(ans, j);
break;
}
}
}
cout << ans << endl;
return 0;
}