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

#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;

bool cmp1(int a,int b)
{
	return a>b;
}

int main()
{
	int n,a[100];
	while (cin >> n && n!=0 )
	{
		for (int i=0;i<n;i++)
		{
			cin >> a[i];
		}
		sort(a,a+n,cmp1);
		int ans=0;
		if (a[n-1]<2) 
		{
			ans=-1;
		}
		else
		{
			for (int i=0;i<n-1;i++)
				ans+=a[i];
			ans+=2;
		}
		cout << ans << endl;
	}
}