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: 1720kB
Author: 2018212212059
In contest: 1275

#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <deque>
#define clr(a,b) memset(a,b,sizeof(a))
#define ll long long

using namespace std;

const int maxn=1e3+10;
int n;
int a[maxn];

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