#include<stdio.h>
#include<stdlib.h>
int comp(const void *a, const void *b)
{
return *(int *)a - *(int *)b;
}
int main()
{
int n, i, count;
int a[101];
while(scanf("%d", &n), n)
{
count = 0;
for (i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
}
qsort(a + 1, n, sizeof(int), comp);
for (i = n; i >= 1; i--)
{
if (a[i] < 2)
{
printf("-1\n");
goto aa;
}
else
{
if (i == 1)
count += 2;
else
count += a[i];
}
}
printf("%d\n", count);
aa:;
}
return 0;
}