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: 3280kB
Author: 2018212212317
In contest: 1275

#include<cstring>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 200010;
const int inf = 0x3f3f3f3f;
const int mo = 1e9+7;
int t,n,m,l,r,ans,cnt;
int a[maxn],b[maxn];
int main(){
	while(cin>>t){
		if(t==0)break;
		int flag=0;
		for(int i=0;i<t;i++){
			cin>>a[i];
			if(a[i]<2) flag=1;
		}
		if(flag==1) cout<<"-1"<<endl;
		else{
			sort(a,a+t);
			ans=0;
			for(int i=1;i<t;i++){
				ans+=a[i];
			}
			cout<<ans+2<<endl;
		}
		
	}
	return 0;
}