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: 7ms
Memory: 1096kB
Author: 2018212212125
In contest: 1275

#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn = 110;
const int inf = 0x3f3f3f3f;
int  x, y, n;
int a[maxn];
int main()
{
	while (scanf("%d", &n) && n) 
	{
		int flag = 0;
		for (int i = 1; i <= n; ++i) {
			scanf("%d", &a[i]);
			if (a[i] == 1||a[i]==0)
				flag = 1;
		}
		if (flag)
			printf("-1\n");
		else 
		{
				sort(a + 1, a + 1 + n);
				reverse(a + 1, a + 1 + n);
				int ans = 0;
				for (int i = 1; i < n; ++i)
					ans += a[i];
				ans += 2;
				printf("%d\n", ans);
		}
	}
	return 0;
}