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: 1716kB
Author: 2018212212124
In contest: 1275

#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stdlib.h>
#include<set> 
#include<vector>
using namespace std;
const int maxn = 110;
const int inf = 0x3f3f3f3f;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	int n;
	int a[110];
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		int flag=0;
		int sum=0;
		int minn=inf;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			sum+=a[i];
			if(a[i]<minn)minn=a[i];
			if(a[i]<=1){
				flag=1;
			} 
		}
		if(flag==1)printf("-1\n");
		else{
			if(n==1)printf("2\n");
			else
				printf("%d\n",sum-minn+2);
				
			
		}
	}
}