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: 2018212212198
In contest: 1275

#include<stdio.h>
int main()
{
	int n;
	int Ai[1000];
	int i,sum,min;
	
	while(scanf("%d",&n),n){
		sum=0;
		min=501;
		int flag=1;
		for(i=0;i<n;i++){
			scanf("%d",&Ai[i]);
			sum=sum+Ai[i];
			if(Ai[i]<2){
				flag=0;
			}
			if(Ai[i]<min){
				min=Ai[i];
			}
			
		}
		if(flag==1){
			printf("%d\n",sum-min+2);
		} else{
			printf("-1\n");
		}
	}
}