Result: Accepted
Time: 7ms
Memory: 1716kB
#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);
}
}
}