#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(){
int T;
int a[502],b,n,m;
while(scanf("%d",&n)!=EOF&&n!=0){
b=0;
for(int i=1;i<=n;++i){
cin>>a[i];
}
m=a[1];
for(int i=1;i<=n;++i){
if(m>a[i])
m=a[i];
}
for(int i=1;i<=n;++i){
if(a[i]>=2) {
if(a[i]!=m)
b+=a[i];
if(a[i]==m)
b+=2;
}
if(a[i]<2) {
b=0;
break;
}
}
if(b!=0)
cout<<b<<endl;
else if(b==0)
cout<<-1<<endl;
}
return 0;
}