背包。
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <ctime>
#include <set>
#include <map>
#define fo(i,j,k) for(int i(j);i<=k;i++)
#define fd(i,j,k) for(int i(j);i>=k;i--)
#define go(i,k) for(int i(head[k]),v(e[i].to);i;i(e[i].nxt),v(e[i].to))
using namespace std;
typedef long long ll;
typedef double db;
const int inf=0x3f3f3f3f;
inline int rd() {
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
return x*f;
}
const int N=305;
int n,a[N],sum;bool f[100005];
int main() {
#ifdef HSZ
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
n=rd();
fo(i,1,n) a[i]=rd(),sum+=a[i];
int mid=sum>>1,ans=0;
sort(a+1,a+1+n);
f[0]=1;
fd(i,n,1)
fd(j,sum,a[i]) {
f[j]|=f[j-a[i]];
if(j>mid&&f[j]&&j-a[i]<=mid) {
ans=max(ans,j);
}
}
cout<<ans<<endl;
return 0;
}