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: 5ms
Memory: 1716kB
Author: 2017210904069
In contest: 1275

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int n,a[502],sum,i;
	while(scanf("%d",&n),n){
		sum = 0;
		memset(a,0,sizeof(a));
		for(i = 0;i<n;i++){
			scanf("%d",&a[i]);
		}
		sort(a,a+n);
		
			if(a[0]<2){
				printf("-1\n");
			}
			else{
				for(i = 1;i<n;i++){
					sum += a[i];
				}
				printf("%d\n",2+sum);
			}
	}
}