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: 6ms
Memory: 1712kB
Author: 2018212212137
In contest: 1275

#include<iostream>
#include<algorithm>
using namespace std;
int a;
int main()
{
	int n;

	while(cin>>n)
	{	
		if(n==0)	break;
		int sum=0;
		int min1=2147483647;
		int flag=1;
		for(int i=0;i<n;i++)
		{
			cin>>a;
			if(a<min1)
			min1=a;
			if(a<2)
			{
				flag=0;
				
				
			}
			else
			{
				sum+=a;
			}
		
		}	
		if(flag==1)
		{	
			sum=sum-min1+2;
			cout<<sum<<endl;
		}
		else
		{
			cout<<"-1"<<endl;
		}
	
	}
}