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

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

int main()
{
	int n;
	while(scanf("%d",&n),n)
	{
		int a[105];
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
		}
		sort(a+1,a+1+n);
		if(a[1]<2)
			printf("-1\n");
		else 
		{
			int ans=0;
			for(int i=n;i>1;i--)
				ans+=a[i];
			ans+=2;
			cout<<ans<<endl;
		}
	}
	return 0;
}