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

#include <bits/stdc++.h>

using namespace std;

int p[105];

int main() {
	int n,sum;
	while(cin>>n,n!=0){
		for(int i=0;i<n;i++){
			cin>>p[i];
		}
		sort(p,p+n);
		sum=0;
		if(p[0]>1){
			for(int i=1;i<n;i++){
				sum+=p[i];
			}
			sum+=2;
		}
		if(!sum)cout<<-1<<endl;
		else cout<<sum<<endl;
	}
	return 0;
}