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: 1716kB
Author: 2018212212171
In contest: 1275

#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int ans=0;
		if(n==0) break;
		int flag=0;
		int a[505]={0};
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
			if(a[i]<2)
				flag=1;
		}
		if(flag) 
		{cout<<"-1\n";continue;}
		sort(a,a+n);
		for(int i=1;i<n;i++)
		{
			ans+=a[i];
		}
		ans+=2;
		cout<<ans<<endl;
	}
}