Start: Jun, 27, 2019 08:30:00
2019年度暑期短学期第二天
End: Jun, 27, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 5ms
Memory: 1092kB
Author: 2018212212140
In contest: 1275

#include<stdio.h>
int min(int a,int b)
{
	if(a>=b)
	{
		return b;
	}
	else
	{
		return a;
	}
}
int main()
{
	int T,a[510],i,t,n,m,s;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;++i)
		{
			scanf("%d",&a[i]);
		}
		if(n==0)
		{
			break;
		}
		
		if(n==1&&a[0]>=2)
		{
			printf("2\n");
		}
		else if(n==1&&a[0]<2)
		{
			printf("-1\n");
		}
		else if(n>1)
		{
			t=0;
			m=0;
			s=a[0];
			for(i=0;i<n;++i)
		    {
		    	if(a[i]<2)
		    	{
		    		printf("-1\n");
		    		break;
				}
				else
				{
					t=t+1;
					m=m+a[i];
					s=min(s,a[i]);
				}
	    	}
	    	if(t==n)
	    	{
	        	printf("%d\n",m-s+2);
			}
	    	
		}
	}
	
	
	
	
}