#include<bits/stdc++.h>
#define rint register int
#define mmt(a,b) memset(a,b,sizeof(a))
#define test(x) cout<<#x<<" = "<<x<<endl
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define endl '\n'
#define enter putchar(endl)
using namespace std;
inline void read(int &x);
inline void ffout(int x);
inline void ffout(string b);
inline void ffout(int x,char b);
inline void ffout(int x,string b);
inline void print(string name,int a[],int r);
const int inf=0x3f3f3f3f,N=1e2;
int n,top,minx=inf,sum,top2;
int a[N],cnt[N],answer[N];
bool dfs(int ans,int tot,int cur)
{
if(tot==n)
if(cur==ans)return true;
else return false;
if(cur==ans)cur=0;
int l=1,r=top;
while(l<r)
{
int mid=l+r>>1;
if(cur+a[mid]>ans)r=mid;
else l=mid+1;
}
for(rint i=l;i>=1;i--)
{
int x=a[i];
if(!cnt[x])continue;
if(cur+x<=ans)
{
cnt[x]--;
if(dfs(ans,tot+1,cur+x))return true;
cnt[x]++;
}
}
return false;
}
signed main()
{
rint i,j;
cin>>n;
for(i=1;i<=n;i++)
{
int x;
cin>>x;
sum+=x;
if(!cnt[x])a[++top]=x;
cnt[x]++;
minx=min(minx,x);
}
sort(a+1,a+top+1);
int len=sqrt(sum);
for(i=minx;i<=sum;i++)
if(sum%i==0)answer[++top2]=i;
for(i=1;i<=top2;i++)
{
int ans=answer[i];
if(dfs(ans,0,0))
{
ffout(ans);
return 0;
}
}
return 0;
}
inline void ffout(string b)
{
int len=b.size();
for(rint i=0;i<len;++i)putchar(b[i]);
}
inline void read(int &x)
{
int f=1;x=0;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
x=x*f;
}
inline void ffout(int x)
{
if(x<0){x=-x; putchar('-'); }
short sta[63],top=0;
do{ sta[top++]=x%10; x/=10; }while(x);
while(top) putchar(sta[--top]+'0');
}
inline void ffout(int x,char b)
{
if(x<0){x=-x; putchar('-'); }
short sta[63],top=0;
do{ sta[top++]=x%10; x/=10; }while(x);
while(top) putchar(sta[--top]+'0');
putchar(b);
}
inline void ffout(int x,string b)
{
if(x<0){x=-x; putchar('-'); }
short sta[63],top=0;
do{ sta[top++]=x%10; x/=10; }while(x);
while(top) putchar(sta[--top]+'0');
ffout(b);
}
inline void print(string name,int a[],int r)
{
ffout(name);
putchar(':');
for(rint i=1;i<=r;i++)
ffout(a[i],' ');
putchar(endl);
}