//搜索入门 
#include <stdio.h>
#include 
<algorithm>
using namespace std;
int length,a[64],n,sum;
bool ok,v[64]={0};
void dfs(int i,int size,int step){
    
if(size==length)i=0,size=0,step--;
    
if(step==0)ok=1;
    
for(int old=-1;!ok&&i<n;i++)
        
if(!v[i]&&a[i]!=old&&(size+a[i])<=length){
            v[i]
=1;
            old
=a[i];
            dfs(i
+1,size+a[i],step);
            v[i]
=0;
            
if(size==0)return;
        }

}

bool cmp(int x,int y){return x>y;}
int main(){
    
while(scanf("%d",&n),n){
        sum
=0,ok=0;
        
for(int i=0;i<n;i++){scanf("%d",&a[i]);sum+=a[i];}
        sort(a,a
+n,cmp);
        
for(length=a[0];!ok&&length<=sum;length++)
            
if(sum%length==0){
                dfs(
0,0,(sum/length)-1);
                
if(ok)printf("%d\n",length);
            }

    }

    
return 0;
}