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: 1712kB
Author: 2018212212013
In contest: 1275

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n&&n!=0){
		int a[550]={0};
		int flag=0,sum=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			sum+=a[i];
		}
		for(int i=0;i<n;i++){
			if(a[i]<2){
				flag=-1;
				break;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(a[i]>a[j]){
					int temp;
					temp=a[i];a[i]=a[j];a[j]=temp;
				}
			}
		}
		sum=sum-a[0];
		if(flag==-1)
			cout<<flag<<endl;
		else
			cout<<sum+2<<endl;
	}
	return 0;
}