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

#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n;
	while(scanf("%d",&n),n) {
		int a[105];
		int flag = 0;
		int iRet = 0;
		for(int i=0; i<n; i++) {
			scanf("%d",&a[i]);
			if(a[i] < 2) flag = -1;
		}
		if(flag == -1) {
			printf("-1\n");
			continue;
		}
		if(flag == 0) {
			if(n == 1) printf("2\n");
			if(n > 1) {
				sort(a,a+n);
				for(int i=1; i<n; i++) {
					iRet += a[i];
				}
				iRet += 2;
				printf("%d\n",iRet);
			}
		}

	}
	return 0;
}