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

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	int a[510];
	while(scanf("%d",&n) != EOF)
	{
		int tf = 2;
		if(n == 0)
			break;
		for(int i = 0;i < n;++i)
		{
			scanf("%d",&a[i]);
			if(a[i] < 2)
			{
				tf = -1;
			}
		}
		if(tf == -1)
			printf("-1\n");
		else
		{
			sort(a,a+n);
			for(int i = n-1;i > 0;--i)
			{
//				printf("a[%d]=%d\n",i,a[i]);
				tf += a[i];
			}
			printf("%d\n",tf);
		}
	
	}
	return 0;
}