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


#include <cstdio>
#include <algorithm>
#include <iostream>
#include<cstring>
#include<cmath>
using namespace std;
bool cmp(int a,int b)
{return a>b;}
int main()
{
	int n,k,i,a[505],flag;
	while(~scanf("%d",&n))
	{
		if(n==0)break;
		flag=1;k=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			if(a[i]<=1)flag=-1;
		}
		sort(a,a+n,cmp);
		for(i=0;i<n-1;i++)
		{
			k+=a[i];
		}
		k+=2;
		if(flag==-1)k=-1;
		printf("%d\n",k);
	}

}