#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int s[65]; int vis[65]; int n; int sum; bool DFS(int cur,int index,int num,int single) { if(num==sum/single-1) return true; for(int i=index;i<n;i++) { if(!vis[i]) { if(cur+s[i]>single) continue; if(cur+s[i]==single) { vis[i]=1; if(DFS(0,0,num+1,single)) return true; vis[i]=0; return false; } else { vis[i]=1; if(DFS(cur+s[i],i+1,num,single)) return true; vis[i]=0; if(cur==0) return false; while(s[i]==s[i+1]) i++; } } } return false; } bool cmp(int a,int b) { return a>b; } int main() { int i; while(scanf("%d",&n)!=EOF&&n!=0) { memset(vis,0,sizeof(vis)); sum=0; for(i=0;i<n;i++) { scanf("%d",&s[i]); sum+=s[i]; } sort(s,s+n,cmp); i=1; for(i=s[0];i<=sum;i++) if(!(sum%i)) { if(DFS(0,0,0,i)) break; } printf("%d\n",i); } return 0; }