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: 10ms
Memory: 1716kB
Author: 2018212212154
In contest: 1275

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
const int maxn=1e3;
using namespace std;
int main()
{
	int b,c,t,n,m;
	int a[maxn];
	while(cin>>n&&n!=0)
	{
		int flag=1,sum=0;
		for(int i=0;i<n;++i)
		{
			cin>>a[i];
			if(a[i]<2) flag=0;
			sum+=a[i];
		}
		sort(a,a+n);
		if(flag==0) printf("-1\n");
		else printf("%d\n",sum-a[0]+2);
	}
}