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: 7ms
Memory: 2160kB
Author: 2018212212122
In contest: 1275

#include <cstdio>
#include <iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
int n,t,i,j,k;
int a,b,c;
int s[114514];
int gcd(int n,int m){
	int r;
	while(1){
		r=m%n;
		if(r==0)
			break;
		m=n;
		n=r;
	}
	return n;
}
int main()
{
	int flag,sum,min;
	while(~scanf("%d",&n),n)
	{
	    flag=1;
		sum=0;
		min=514;
		for(i=0;i<n;++i){
			cin>>s[i];
			sum+=s[i];
			if(min>s[i])
				min=s[i];
			if(s[i]<2)
				flag=0;
		}
		/*if(n==1){
			if(!flag)
				cout<<"-1"<<endl;
			else{
				cout<<"2"<<endl;
			}
		}
		else*/{
			if(!flag)
				cout<<"-1"<<endl;
			else{
				cout<<sum-min+2<<endl;
			}
			memset(s,0,sizeof s);
		}
	}
	return 0;
}