#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
bool cmp1(int a,int b)
{
return a>b;
}
int main()
{
int n,a[100];
while (cin >> n && n!=0 )
{
for (int i=0;i<n;i++)
{
cin >> a[i];
}
sort(a,a+n,cmp1);
int ans=0;
if (a[n-1]<2)
{
ans=-1;
}
else
{
for (int i=0;i<n-1;i++)
ans+=a[i];
ans+=2;
}
cout << ans << endl;
}
}