#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#define MM 2000005
#define MN 2005
using namespace std;
bitset <MM> s;
int a[MN],n,sum;

inline int read()
{
	int n=0,f=1; char c=getchar();
	while (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}
	while (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}
	return n*f;
}

int main()
{
	register int i;
	n=read();
	for (i=1;i<=n;++i) sum+=a[i]=read();
	s.set(0);
	for (i=1;i<=n;++i) s=s|(s<<a[i]);
	for (i=sum>>1;i;--i)
		if (s.test(i)) {printf("%d ",sum-i); break;}
}