#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int a[510];
while(scanf("%d",&n) != EOF)
{
int tf = 2;
if(n == 0)
break;
for(int i = 0;i < n;++i)
{
scanf("%d",&a[i]);
if(a[i] < 2)
{
tf = -1;
}
}
if(tf == -1)
printf("-1\n");
else
{
sort(a,a+n);
for(int i = n-1;i > 0;--i)
{
// printf("a[%d]=%d\n",i,a[i]);
tf += a[i];
}
printf("%d\n",tf);
}
}
return 0;
}